BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
afrerichs
Calcite | Level 5

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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.

afrerichs
Calcite | Level 5

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? 

Tom
Super User Tom
Super User

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? 


 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 860 views
  • 0 likes
  • 2 in conversation