Hello,
I'm pretty new to SAS and I'm having difficulty importing this dat file.
Hopefully, everyone can see the upper image. So I used the upper codes to see the output and this is what I get:
Basically nothing.. I opened up the dat file in txt and there should be 32 observations and you can see the rest:
I googled and searched on youtube to see what I did wrong and I tried several codings but none of them showed me the full data when I check my output window. Oh, and I checked the log and it said invalid data etc etc (sorry they were too long but i'm pretty sure you get the point). Can you tell me what I did wrong? I am a very novice so please be understanding. Thank you.
The file probably has TAB characters to make it appear in such neat columns. Also if a person had typed using spaces they probably would have aligned the ones place in the first column.
Try adding DSD and DLM='09'x to your INFILE statement after the filename.
If that doesn't work then run a simple data step to check what is actually in the file.
Something like this (I can't use your actual filename since you posted photographs of text instead of just copying the text and sharing that).
data _null_;
infile '/home/......' obs=4;
input;
list;
run;
The file probably has TAB characters to make it appear in such neat columns. Also if a person had typed using spaces they probably would have aligned the ones place in the first column.
Try adding DSD and DLM='09'x to your INFILE statement after the filename.
If that doesn't work then run a simple data step to check what is actually in the file.
Something like this (I can't use your actual filename since you posted photographs of text instead of just copying the text and sharing that).
data _null_;
infile '/home/......' obs=4;
input;
list;
run;
One of the basic tools diagnosing issues with reading files is the LOG created by SAS. That usually has lots of pertinent information. Best is to copy as text from the log the entire step, code and all messages, notes, warnings or errors created, then on the forum open a text box using the </> icon above the message window and paste the text in that box. The text box is important to preserve formatting as the message windows on this forum will reformat text and the text is important as it allows us to copy/paste/edit or highlight bits that are not practically done with images.
Did the file have any header information? Even with most of the likely file format issues the first value of 1 on the first record should have been read. UNLESS you have run the code multiple times with different attempts and are getting a warning like this:(example of text copied from Log and pasted into text box)
WARNING: Data set XXXXXX was not replaced because this step was stopped.
which means that the data set was created, yes not as desired, but the later code is not replacing the previous problem data set.
Also the note at the top of your data set showing only 6 rows makes me suspect you may be having an issue with end of line characters being inconsistent.
You need to add the Delimiter to your INFILE statement, like a tab.
infile 'path' dlm='09'x truncover;
PS. Please post your code and log as text, not images in the future. If you post it as text, we can easily copy/paste/fix it. Otherwise it requires typing it out.
@eeun1ilee wrote:
Hello,
I'm pretty new to SAS and I'm having difficulty importing this dat file.
Hopefully, everyone can see the upper image. So I used the upper codes to see the output and this is what I get:
Basically nothing.. I opened up the dat file in txt and there should be 32 observations and you can see the rest:
I googled and searched on youtube to see what I did wrong and I tried several codings but none of them showed me the full data when I check my output window. Oh, and I checked the log and it said invalid data etc etc (sorry they were too long but i'm pretty sure you get the point). Can you tell me what I did wrong? I am a very novice so please be understanding. Thank you.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.