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

Hello!

I am trying to import a txt file that has a table (delimited by spaces), which also has column headers. The txt file looks as follows:

City State Price
Baltimore MD 10.95
Brooklyn NY 12.99
Buffalo NY 11.50
Harlem NY 12.50
Newark NJ 11.50
Rochester NY 10.95
Stamford CT 11.50
Syracuse NY 10.95
Troy NY 11.50

 

And my code so far looks like this:

 

DATA Ribs;
INFILE '/folders/myfolders/sasuser.v94/DinosaurBBQRibs.txt' DLM='';
INPUT City :$9. State :$2. Price :COMMA6.2 @@;
RUN;

 

My table looks fine, except the first row includes City and State, and a . for price, but I don't want to include them there and I can't seem to get it correct.

issue sas.png

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Add firstobs=2 to the infile statement. And remove the @@, that's for creating many obs with each line.

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Add firstobs=2 to the infile statement. And remove the @@, that's for creating many obs with each line.

PG
daft22
Fluorite | Level 6

Thank you so much! I appreciate your help!

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

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
  • 2 replies
  • 1352 views
  • 1 like
  • 2 in conversation