i have multiple .csv files in a unix directory.
every file is having variable names as header.even for empty file also.
suppose take 3 files
a.csv
b.csv
c.csv
a.csv contains data as
name;age,salary;
raja;34;4000;
ravi;33;5000;
kumar;25;3000;
b.csv contains data as
name;age,salary;
ajay;40;4500;
and c.csv contains
name;age,salary; (only headers)
Now i want to import and append all these files in to a single dataset.
i tried infile statement with *.csv to import all at a time.
but i m not getting correct data.
please help me . its urgent.
thank you in advance
Answer Posted / vrana95
/*step 1: create a macro for the destination folder */
%let dirname = C:UsersRANAJIDesktopSAS_Class_CodeMultiple_csv_files;
filename DIRLIST pipe "dir /B &dirname*.csv";
data dirlist ;
length fname $256;
infile dirlist length=reclen;
input fname $varying256. reclen ;
run;
proc print data = dirlist;
run;
/* step 2 , append all the files in one. */
data all_text (drop=fname);
length myfilename $100;
length name $25;
set dirlist;
filepath = "&dirname"||fname;
infile dummy filevar = filepath length=reclen end=done missover;
do while(not done);
myfilename = filepath;
input name $ x1 x2 x3;
output;
end;
run;
proc print data=all_text;
run;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Mention what are the data types does SAS contain?
I have a dataset concat having a variable a b & c. How to rename a b to e & f?
Differentiate between proc means and proc summary.
what is the effect of the options statement errors=1? : Sas programming
what is slowly changing dimension? : Sas-di
What are the data types does SAS contain?
Difference between SAS STATA & SPSS?
What is auto call macro and how to create a auto call macro? What is the use of it? How to use it in sas with macros? : sas-macro
Why and when do you use proc sql?
What is factor analysis?
Are you involved in writing the inferential analysis plan? Tables specfications?
Explain the use of proc gplot? : sas-grid-administration
What is proc sort?
what other sas products have you used and consider yourself proficient in using? : Sas programming
Hi Friends, Am Priya,new to your forum. am looking for Interview questions on SAS Platform Administration. I searched everywhere but I couldn't find them,please can anyone help me with complete interview questions normally everyone will face in the interviews on SAS Administration. am really facing problems in the interviews,am not able to answer any of their questions. I would really appreciate all your help if you can email the complete Interview Questions to priyafeb84@gmail.com Kindly awaiting for your reply with eager