When I try to export a dataset with 1900 variables as a CSV, the output only contains a certain number of variable names and then the rest are just blanks.
I tried this code instead of proc export:
proc transpose data=final(obs=0) out=names ; run;
data _null_;
file 'myfile.csv' dsd ;
set names end=eof;
put _name_ @;
if eof then put;
run;
data _null_;
set final ;
file 'myfile.csv' dsd mod ;
put (_all_) (+0);
run;
But it STILL cut off the variable names. How can I fix this?
Tell SAS to use a longer line length.
file 'myfile.csv' dsd lrecl=1000000;
You must have some really strange variable names. The default record length is 32,767 which for 1,900 means your average variable name must be over 16 characters long!
1192 data _null_; 1193 x=(32767-1899)/1900; 1194 put x=; 1195 run; x=16.246315789
Good luck trying to write any code to use such a dataset.
Tell SAS to use a longer line length.
file 'myfile.csv' dsd lrecl=1000000;
You must have some really strange variable names. The default record length is 32,767 which for 1,900 means your average variable name must be over 16 characters long!
1192 data _null_; 1193 x=(32767-1899)/1900; 1194 put x=; 1195 run; x=16.246315789
Good luck trying to write any code to use such a dataset.
Thank you! I was able to get it to work. Yes, unfortunately this dataset has crazy variable names.
My next question in case you know the answer, I want the output csv to be named "OUTPUT_File.csv", but it is outputting it as "Output_File.csv". Do you know if there is a way around this?
Since the code you posted is going to make a file named myfile.csv you need show what code you actually are running.
If the "Output" part is coming from a macro variable of some sort perhaps you just need to add a call to the %UPCASE() macro function?
@afrerichs wrote:
Thank you! I was able to get it to work. Yes, unfortunately this dataset has crazy variable names.
My next question in case you know the answer, I want the output csv to be named "OUTPUT_File.csv", but it is outputting it as "Output_File.csv". Do you know if there is a way around this?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.