Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Can you execute a macro within a macro? Describe. : sas-macro

1102


What is the sas data set? : sas-grid-administration

971


what is a method for assigning first.var and last.var to the by groupvariable on unsorted data? : Sas programming

998


what are the component of range? : Sas-bi

1078


Are you involved in writing the inferential analysis plan? Tables specifications?

3943


Briefly explain input and put function?

1071


Describe the ways in which you can create macro variables? : sas-macro

1056


how to debug and test the sas program? : Sas-administrator

1027


For clinical entire study how many tables will create approx?

1961


what are all the reports you generated in your recent project?

2190


What is PROC in SAS?

1043


how do you pull data from equifax?tell me the process?

1789


what are the new features included in the new version of sas i.e., Sas 9.1.3? : Sas programming

1068


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

1032


Name any two sas spawners? : sas-grid-administration

1035