Coding Exercise (Answer)

h

**** Question 1 ****;

** BORROWED.CSV **;
filename borrowed '/home/your_user_name/proc_import/borrowed.csv';

proc import datafile=borrowed
  dbms=csv
  out =borrowed
  replace;
  guessingrows=max;
run;

** DEMOGRAPHICS.CSV **;
filename demo '/home/your_user_name/proc_import/demographics.csv';

proc import datafile=demo
  dbms=csv
  out =demo
  replace;
  guessingrows=max;
run;

** Q8.CSV **;
filename q8 '/home/your_user_name/proc_import/q8.csv';

proc import datafile=q8
  dbms=csv
  out =q8
  replace;
  guessingrows=max;
run;

**** Question 2 ****;

** RISK STRATIFICATION.XLSX **;

** Method 1 **;
libname risk xlsx '/home/your_user_name/proc_import/risk stratification.xlsx';

** Method 2 **;
filename risk '/home/your_user_name/proc_import/risk stratification.xlsx';

proc import datafile=risk
  dbms=xlsx
  out =risk
  replace;
run;

** ADC.XLSX **;

** Method 1 **;
libname adc xlsx '/home/your_user_name/proc_import/adc.xlsx';

** Method 2 **;
filename adc '/home/your_user_name/proc_import/adc.xlsx';

proc import datafile=adc
  dbms=xlsx
  out =adc
  replace;
  sheet = 'QUERY RESULTS';
run;

proc import datafile=adc
  dbms=xlsx
  out =adc
  replace;
  sheet = 'SUMMARY';
run;

** GENE.XLSX **;

** Method 1 **;
libname gene xlsx '/home/your_user_name/proc_import/gene.xlsx';

** Method 2 **;
filename gene '/home/your_user_name/proc_import/gene.xlsx';

proc import datafile=gene
  dbms=xlsx
  out =gene
  replace;
  sheet = 'DATA';
run;

proc import datafile=gene
  dbms=xlsx
  out =gene
  replace;
  sheet = 'TRANSPOSED';
run;

** RANCOL.XLSX **;

** Method 1 **;
libname rancol xlsx '/home/your_user_name/proc_import/rancol.xlsx';

** Method 2 **;
filename rancol '/home/your_user_name/proc_import/rancol.xlsx';

proc import datafile=rancol
  dbms=xlsx
  out =rancol
  replace;
run;

**** Question 3 ****;

** HOTELS.TXT **;
filename hotels '/home/your_user_name/proc_import/hotels.txt';

proc import datafile=hotels
  dbms=tab
  out =hotels
  replace;
  delimiter = '09'x;
  guessingrows=max;
run;

** BEATLES.TXT **;
filename beatles '/home/your_user_name/proc_import/beatles.txt';

proc import datafile=beatles
  dbms=dlm
  out =beatles
  replace;
  delimiter = ';';
  guessingrows=max;
run;

** SURVEY.TXT **;
filename survey '/home/your_user_name/proc_import/survey.txt';

proc import datafile=survey
  dbms=dlm
  out =survey
  replace;
  delimiter = ',';
  guessingrows=max;
run;