DATA Step, Macro, Functions and more

Using Export button in SAS EG versus PROC EXPORT causes issues

Reply
New Contributor
Posts: 3

Using Export button in SAS EG versus PROC EXPORT causes issues

I have a certain SAS dataset I need to export as a CSV file in order to import it into a different software program. When I click the Export button, the CSV file exports nicely, and I change a few variable names that were shortened by the 32 character cap, and import into the different software.

 

This can get tedious, so I am trying to use PROC SQL to give each variable a label with its proper name, whether it has fewer than 32 characters or more, and automatically export as a CSV, using the labels for headers instead of the variable names. My issue is, when I use PROC EXPORT, my CSV files comes out differently, and it won't import into my software. I notice the PROC EXPORT CSV file has quotations around each variable name in the header-- they don't have quotations when I use the Export button-- and each row of data is not necessarily on it's own row, as it is when I use the Export button. Any thoughts on how I could fix either of these issues? I'm not sure which is causing the issue with the other software program. Here's the PROC EXPORT code I'm using. Thanks for reading.

 

proc export
data = WORK.MY_DATA
outfile = "&folderpath./&filename..csv"
label
dbms = csv
replace;
run;

Super User
Posts: 23,683

Re: Using Export button in SAS EG versus PROC EXPORT causes issues

Posted in reply to leftygrove

Labels can have spaces or comma's so that's why your headers are now in quotes.

Just a guess on the second issues - when you export in PROC EXPORT is it running on the same OS? Is SAS EG on a server? If so, it may be creating a file with UNIX characters rather than Window EOL characters.

 


@leftygrove wrote:

I have a certain SAS dataset I need to export as a CSV file in order to import it into a different software program. When I click the Export button, the CSV file exports nicely, and I change a few variable names that were shortened by the 32 character cap, and import into the different software.

 

This can get tedious, so I am trying to use PROC SQL to give each variable a label with its proper name, whether it has fewer than 32 characters or more, and automatically export as a CSV, using the labels for headers instead of the variable names. My issue is, when I use PROC EXPORT, my CSV files comes out differently, and it won't import into my software. I notice the PROC EXPORT CSV file has quotations around each variable name in the header-- they don't have quotations when I use the Export button-- and each row of data is not necessarily on it's own row, as it is when I use the Export button. Any thoughts on how I could fix either of these issues? I'm not sure which is causing the issue with the other software program. Here's the PROC EXPORT code I'm using. Thanks for reading.

 

proc export
data = WORK.MY_DATA
outfile = "&folderpath./&filename..csv"
label
dbms = csv
replace;
run;


 

Ask a Question
Discussion stats
  • 1 reply
  • 34 views
  • 0 likes
  • 2 in conversation