In SAS, we can write macro for importing files. The macro can be of the form:
%MACRO IMPORT_Data(OUT = , FILE = );
data &OUT ;
infile "&INPUT_path.\&File"
delimiter = ',' MISSOVER DSD lrecl=32767
firstobs=2 ;
input
Var1 : $10.
Var2 : best12.
Var3 : Percent5.2
Var4
Var5
;
%mend;
Once we have this macro, we just need to change the filename, and run the macro. We don’t need to write the import file syntax everytime we read the file. Can anybody help me to get the version in R? A reference is also greatly appreciated.
You are looking for a function. A user defined function to read a specified
csvfile, apply some formatting to one or more of the columns, and return the result. Here is one example:Then you just run: