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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 698 views
  • 1 like
  • 2 in conversation