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.
Add firstobs=2 to the infile statement. And remove the @@, that's for creating many obs with each line.
Add firstobs=2 to the infile statement. And remove the @@, that's for creating many obs with each line.
Thank you so much! I appreciate your help!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.