BookmarkSubscribeRSS Feed
braveblade
Fluorite | Level 6

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!

3 REPLIES 3
Rick_SAS
SAS Super FREQ

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.

braveblade
Fluorite | Level 6

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

ballardw
Super User

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.

sas-innovate-2024.png

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.

 

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
  • 3 replies
  • 844 views
  • 0 likes
  • 3 in conversation