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

Hi,

 I'm using SAS on demand version. I am trying to read in the txt file in to sas, but I met some problems.

I have a dataset shown as below.

rrr.png

 

And I try for a few lines of code as shown in the picture. I am confused about the delimiter and I try on "09"X.

khdf.png

 

However, the output dataset appears all dot without any values, any suggestions will really appreciate.

 

dfdfd.png

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

I don't think it it is a tab aka '09'x delimited file. I think it is a just delimited by blanks.

Try the simple and let us know

 

data beer_drug;
infile "home/stat440/beer_drug.txt" dlm=' ';
input RI_KEY WEEK SY GE VEND ITEM UNITS DOLLARS F $ D PR ;

run;

View solution in original post

8 REPLIES 8
novinosrin
Tourmaline | Level 20

Post the txt file and not pics plz. I have no way of testing

233
Calcite | Level 5 233
Calcite | Level 5

Sorry, the txt file is too large and can not be attached. If without the txt file, is it possible for you to give me some advice like change the delimiter or something? Thanks

novinosrin
Tourmaline | Level 20

Lol  didnt mean the full txt file. Please paste like 10 records as plain txt rather than as pics for the community to be able to copy paste the data and run a code against/with it

233
Calcite | Level 5 233
Calcite | Level 5

Sorry I'm newbie, still struggling for the basic.

I have paste the data below, will that be okay?

 

IRI_KEY WEEK SY GE VEND ITEM UNITS DOLLARS F D PR
664497 1114 0 2 33200 19180 1 2.73 NONE 0 0
664497 1114 0 2 22600 2062 2 6.38 NONE 0 0
664497 1114 0 3 22200 3 1 2.95 NONE 0 0
664497 1114 0 1 22200 500 1 1.79 NONE 0 0
664497 1114 0 1 22200 960 1 0.99 NONE 0 0
664497 1114 0 1 22200 95104 1 3.19 NONE 0 0
664497 1114 0 3 22200 315 2 3.98 NONE 0 0
664497 1114 0 2 22200 324 1 1.99 NONE 0 0
664497 1114 0 1 22200 865 4 3.96 NONE 0 0
664497 1114 0 2 22200 93043 1 2.99 NONE 0 0
664497 1114 0 1 79400 60420 1 3.79 NONE 0 0
664497 1114 0 1 47400 27517 2 6.98 NONE 0 0
664497 1114 0 1 47400 27509 1 2.99 NONE 0 0
664497 1114 0 1 47400 27520 1 2.99 NONE 0 0
664497 1114 0 1 47400 13138 4 13.96 NONE 0 0

novinosrin
Tourmaline | Level 20

I don't think it it is a tab aka '09'x delimited file. I think it is a just delimited by blanks.

Try the simple and let us know

 

data beer_drug;
infile "home/stat440/beer_drug.txt" dlm=' ';
input RI_KEY WEEK SY GE VEND ITEM UNITS DOLLARS F $ D PR ;

run;

233
Calcite | Level 5 233
Calcite | Level 5

Thank you! I try on the blank and it works.

I have another concern that all the dataset starts on the second row, and the first row appears dot. Is there anything I could do to fix that?

 

novinosrin
Tourmaline | Level 20

My bad and my apologies as I am on the 3rd pint lol

 

Add the option firstobs=2 in the infile statement

 

infile "home/stat440/beer_drug.txt" dlm=' ' firstobs=2;

 

this option enables to start reading records from 2nd record

233
Calcite | Level 5 233
Calcite | Level 5

It works! Thank you!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 8 replies
  • 1979 views
  • 0 likes
  • 2 in conversation