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".

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 694 views
  • 0 likes
  • 3 in conversation