In chapter 2.10 of Little SAS Book. There is an example data file named canoes as follows:
Bellatorum School: CSULA Time: 1:40.5
The Kraken School: ASU Time: 1:45.35
Black Widow School: UoA Time: 1:33.7
Koicrete School: CSUF Time: 1:40.25
Khaos School: UNLV Time: 2:03.45
Max School: UCSD Time: 1:26.47
Hakuna Matata School: UCLA Time: 1:20.64
Prospector School: CPSLO Time: 1:12.08
Andromeda School: CPP Time: 1:25.1
Kekoapohaku School: UHM Time: 1:24.49
The book shows how to read "School" and "Time" use colon modifier, but does not show how to read the entire data file, which should include the first variable: Canoe team's names. I tried it but with no success. I'm having trobule reading the "Hakuna Matata" part. It has a space in between and the delimiter of the data file is space. Can anyone show me how to read the above data file into SAS? Thanks!
I don't know what edition you are using, but the fifth edition includes the following code, which appears to read the RaceTime variable:
DATA canoeresults;
INFILE 'c:\MyRawData\Canoes.dat';
INPUT @'School:' School $ @'Time:' RaceTime :STIMER8.;
RUN;
The RaceTime variable will be read in terms of seconds. For example, the first observation has a RaceTime of 100.5 seconds.
Yes. But it does not show how to read the first variable: Canoe team's name. Thanks!
Add before the input:
Informat teamname $20. ;
modify input
input teamname & <the other variables>
This assumes that the important but not mentioned two spaces after the team names is consitent.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.