DATA Step, Macro, Functions and more

How to read the canoes example date in Little SAS Book into SAS

Reply
Occasional Contributor
Posts: 6

How to read the canoes example date in Little SAS Book into SAS

[ Edited ]

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!

SAS Super FREQ
Posts: 3,756

Re: How to read the canoes example date in Little SAS Book into SAS

Posted in reply to braveblade

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.

Occasional Contributor
Posts: 6

Re: How to read the canoes example date in Little SAS Book into SAS

Yes. But it does not show how to read the first variable: Canoe team's name. Thanks!

Super User
Posts: 11,343

Re: How to read the canoes example date in Little SAS Book into SAS

Posted in reply to braveblade

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.

Ask a Question
Discussion stats
  • 3 replies
  • 237 views
  • 0 likes
  • 3 in conversation