- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I got a problem when I tried to export data from a data set to a text file. I'm wondering if anyone can help 🙂
So below is my code:
data _null_;
set sashelp.class;
file '/folders/myfolders/class.txt';
put name age height;
run;
I'm trying to export the name, age and height variables to a text file. The variables are from sashelp.class and I'm running the code on SAS Studio.
I'm expecting the data to be exported record by record. So if there are 19 records in sashelp.class, I am expecting the text file will have 19 records as well.
However, when I look at the text file, all the records stayed in one line. It looks like this:
Alfred 14 69Alice 13 56.5Barbara 13 65.3Carol 14 62.8Henry 14 63.5James 12 57.3Jane 12 59.8Janet 15 62.5Jeffrey 13 62.5
Does anyone know why?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As @Reeza said, you are reading a unix file under Windows.
Try:
data _null_;
set SASHELP.CLASS;
file '/folders/myfolders/class.txt' termstr=CRLF;
put NAME AGE HEIGHT;
run;
and look up the reasons for this (minor) nonsense if you want. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Works fine for me. Check your Text Editor 'wrap text' option settings.
Another possibility is since this was created on Unix it's using a Unix end of line character that the text editor isn't understanding. Turn on invisible characters to see what's happening there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As @Reeza said, you are reading a unix file under Windows.
Try:
data _null_;
set SASHELP.CLASS;
file '/folders/myfolders/class.txt' termstr=CRLF;
put NAME AGE HEIGHT;
run;
and look up the reasons for this (minor) nonsense if you want. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Open the file with a more versatile tool like Notepad++. This will tell you the file type (UNIX) in the status line, and siplay the data correctly. To satisfy basic Windows software (like the simple Editor), use the termstr=CRLF option as @ChrisNZ suggested.