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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.