BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Steelersgirl
Calcite | Level 5

I am having trouble reading in a data file from http://people.stat.sc.edu/Hitchcock/beatles_songlengths.txt. The first variable is the album name and the rest of the variable are the song lengths for the 14 songs in the album. First the minute variable, then the seconds variable. Two of the albums only have 13 songs and the missing variable is replaced by '.'. This is the code I tried to read in the data, but it is not creating the correct table. 

 

DATA songs;
FILENAME webpage URL 'http://people.stat.sc.edu/Hitchcock/beatles_songlengths.txt';
INFILE webpage MISSOVER DLM=' ';
INPUT album_name $ min1 sec1 min2 sec2 min3 sec3 min4 sec4 min5 sec5 min6 sec6 min7 sec7 min8 sec8 min9 sec9 min10 sec10 min11 sec11 min12 sec12 min13 sec13 min14 sec14;
RUN;


PROC PRINT DATA=songs;
RUN;
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

DATA songs;
FILENAME webpage URL 'http://people.stat.sc.edu/Hitchcock/beatles_songlengths.txt';
INFILE webpage ;
 INPUT album_name  $ 1-38 min1 sec1 min2 sec2 min3 sec3 min4 sec4 min5 sec5 min6 sec6 min7 sec7 min8 sec8 min9 sec9 min10 sec10 min11 sec11 min12 sec12 min13 sec13 min14 sec14;
 RUN;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

DATA songs;
FILENAME webpage URL 'http://people.stat.sc.edu/Hitchcock/beatles_songlengths.txt';
INFILE webpage ;
 INPUT album_name  $ 1-38 min1 sec1 min2 sec2 min3 sec3 min4 sec4 min5 sec5 min6 sec6 min7 sec7 min8 sec8 min9 sec9 min10 sec10 min11 sec11 min12 sec12 min13 sec13 min14 sec14;
 RUN;
ballardw
Super User

@Steelersgirl wrote:

I am having trouble reading in a data file from http://people.stat.sc.edu/Hitchcock/beatles_songlengths.txt. The first variable is the album name and the rest of the variable are the song lengths for the 14 songs in the album. First the minute variable, then the seconds variable. Two of the albums only have 13 songs and the missing variable is replaced by '.'. This is the code I tried to read in the data, but it is not creating the correct table. 

 

DATA songs;
FILENAME webpage URL 'http://people.stat.sc.edu/Hitchcock/beatles_songlengths.txt';
INFILE webpage MISSOVER DLM=' ';
INPUT album_name $ min1 sec1 min2 sec2 min3 sec3 min4 sec4 min5 sec5 min6 sec6 min7 sec7 min8 sec8 min9 sec9 min10 sec10 min11 sec11 min12 sec12 min13 sec13 min14 sec14;
RUN;


PROC PRINT DATA=songs;
RUN;

If you do not define a length for a character variable or tell how wide the field may be then the result will default to 8 characters.

 

You really should describe the actual symptom(s) not a vague statement like " but it is not creating the correct table".

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 586 views
  • 0 likes
  • 3 in conversation