08-24-2016 10:07 AM - edited 08-24-2016 10:12 AM
How do i write out the same file to different locations?
Eg, i tried 2 file statements, but i realised the file in the first statement is empty.
FILENAME OUT 'C:\desktop\dataset1.dat'
FILENAME OUT1 'C:\desktop\data\dataset1.dat'
data out; Set dataset1; File out; File out1; put @1 variable1; run;
08-24-2016 10:15 AM
You can only write to one file at any given moment; that is why the first file is empty, as the second file statement takes precedence.
This is where a macro may be handy to avoid writing several data steps:
%macro write_file(outfilename); data _null_; set dataset1; file "&outfilename"; put @1 variable1; run; %mend; %write_file(C:\desktop\dataset\out); %write_file(C:\desktop\out);
08-24-2016 10:26 AM
You can do something like this:
You can put as many file and put statements as you like.
Why are you using .dat extension by the way? Use a descriptive file extension, so maybe .txt as it is textual file format, or .csv for comma separated.