- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a SAS data set with one column in character format that looks like this:
ID
239438233
485574323
048573493
495840312
I need to export it to a .txt file, and have it look the same as above when opening the text file. Unfortunately when I export it and open it in notepad I can't get each ID on its own line.
When I export the file I get:
239438233485574323048573493495840312
The 4 IDs come out as on long string. Here's the code I'm using:
PROC EXPORT DATA=USER_IDS;
OUTFILE= "&MYLOCATION/IDS.TXT"
REPLACE;
PUTNAMES=NO;
RUN;
Any ideas on modifications I can make to this block of code to get the desired output?
Thank you!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC EXPORT DATA=USER_IDS;
OUTFILE= "&MYLOCATION/IDS.TXT"
dbms=dlm
REPLACE;
delimiter=' ';
PUTNAMES=NO;
RUN;
If this isn't generating one per row, then consider are you generating the output with unix and looking at it in Windows or vice versa?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You did not specifiy DBMS=, that may be the reason.
In cases like this, I would not use proc export at all;
Try this:
data _null_;
file "&MYLOCATION/IDS.TXT";
set USER_IDS;
put ID;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Kurt! I tried your code and got the same results, where all the IDs come out in one long string. Then I used my code and played with the DMBS= statement, but couldn't get the desired output, which is one ID on each line in the .txt file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC EXPORT DATA=USER_IDS;
OUTFILE= "&MYLOCATION/IDS.TXT"
dbms=dlm
REPLACE;
delimiter=' ';
PUTNAMES=NO;
RUN;
If this isn't generating one per row, then consider are you generating the output with unix and looking at it in Windows or vice versa?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ballardw,
You nailed it. That was the problem. I created the file and put in on the Unix Server. The format was correct there. When I moved it to Windows, that's when it became one long string. To solve the issue, within winscp, I went to Options-->Preferences-->Transfers-->Edit-->
...and under "Transfer Mode" checked the 'Automatic' Box
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your END LINE character is not right . Try :
filename x "&MYLOCATION/IDS.TXT" termstr=lf;
OR
filename x "&MYLOCATION/IDS.TXT" termstr=crlf;
PROC EXPORT DATA=USER_IDS;
OUTFILE=x
REPLACE;
PUTNAMES=NO;
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
filename x "&MYLOCATION/IDS.TXT" termstr=crlf;
- it works.
Thanks,