BookmarkSubscribeRSS Feed
leftygrove
Calcite | Level 5

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;

1 REPLY 1
Reeza
Super User

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;


 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 812 views
  • 0 likes
  • 2 in conversation