hello
i have a dataset for example
PROGRAM DATA
A 21780
A 21781
B 21782
C 21782
C 21783
I need to export the data set into multiple txt files with the variable names from the rows like this:
A_21780.txt
A_21781.txt
B_21782.txt
.
.
.
Only the txt file name, and file can be empty. How i do it?
Thank you.
data have;
input PROGRAM $ DATA;
cards;
A 21780
A 21781
B 21782
C 21782
C 21783
;
data _null_;
set have;
filename=cats('c:\temp\',catx('_',program,data),'.txt');
file dummy filevar=filename;
put (_all_) (:);
run;
I don't understand this. Do you want the TXT files to be empty? If not, what exactly do you want in them?
Hello,
Yes, i only wants the files empty because after splitting them like user Ksharp says , i posteriorly read them in the path for using it in a step of a SAS program that requires this.
thanks.
If data is present, the respective output file will not be empty, if no data for a given program/number combination is present, then that file won't be created.
many thanks,
Yes , data if present but with
put (_all_) (:); instruction then , the files are exported empty.
data have;
input PROGRAM $ DATA;
cards;
A 21780
A 21781
B 21782
C 21782
C 21783
;
data _null_;
set have;
filename=cats('c:\temp\',catx('_',program,data),'.txt');
file dummy filevar=filename;
put (_all_) (:);
run;
thank you, that works!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.