BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eeun1ilee
Fluorite | Level 6

Hello,

I'm pretty new to SAS and I'm having difficulty importing this dat file.

Screenshot 2022-01-14 211641.png

Hopefully, everyone can see the upper image. So I used the upper codes to see the output and this is what I get:

Screenshot 2022-01-14 211607.png

Basically nothing.. I opened up the dat file in txt and there should be 32 observations and you can see the rest:

Screenshot 2022-01-14 211839.png

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

7 REPLIES 7
Tom
Super User Tom
Super User

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;
eeun1ilee
Fluorite | Level 6
Yes, the dlm='09'x and truncover were the magic codes that were missing! Thank you Tom for your help! I really appreciate it!!
Reeza
Super User
Please pick one of the correct answers (Tom's is perfect) and mark that as a solution.
ballardw
Super User

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.

eeun1ilee
Fluorite | Level 6
The file did not have any header 😞 But, thanks to amazing people who replied to my post, I was able to see the dataset! Thank you so much! I really appreciate all your help!
Reeza
Super User

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.

Screenshot 2022-01-14 211641.png

Hopefully, everyone can see the upper image. So I used the upper codes to see the output and this is what I get:

Screenshot 2022-01-14 211607.png

Basically nothing.. I opened up the dat file in txt and there should be 32 observations and you can see the rest:

Screenshot 2022-01-14 211839.png

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.


 

 

eeun1ilee
Fluorite | Level 6
Thank you so much! And, will type out the codes next time. Sorry, this was my first time using this forum. I really appreciate your help!
PS: It worked!

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2091 views
  • 8 likes
  • 4 in conversation