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

1.PNG2.PNG

As you can see, at observation 12, the value should be "Dracula:Dead and Loving It (1995)" for the title. However, I got what's shown in the picture above. This is my code:

 

libname perm '/home/cheok19970/Assignment';
data perm.movies;
informat MovieID 4. Title $60. Genre $50.;
infile '/home/cheok19970/Assignment/movies.dat' dlm=':|';
input MovieID Title $ Genre $;
run;

Since I put colon and vertical pipe as the delimiter, the code is eliminating all the ":" and "|" in the data set. Besides, the output genre only shows one genre. How do i fix it? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The DLMSTR should be :: and then you need to parse GENRE out separately after, because the number of entries there are not consistent, some have 1, some have 3 genres.  Make sure to parse out the year as well. For either you can use the SCAN function.

 

There are some other data issues throughout. 

 

There's actually code on here somewhere on how to read the file properly, someone else asked this already. 

View solution in original post

3 REPLIES 3
Reeza
Super User

DLMSTR in the infile statement. Look it up under the INFILE documentation.

Shrade
Calcite | Level 5

image.png

libname perm '/home/cheok19970/Assignment';
data perm.movies;
	informat MovieID 4. Title $60. Genre $50.;
	infile '/home/cheok19970/Assignment/movies.dat' dlmstr=':|';
	input MovieID Title $ Genre $;
run;

proc print data=perm.movies noobs;
run;

I'm getting weird output 😕

Reeza
Super User

The DLMSTR should be :: and then you need to parse GENRE out separately after, because the number of entries there are not consistent, some have 1, some have 3 genres.  Make sure to parse out the year as well. For either you can use the SCAN function.

 

There are some other data issues throughout. 

 

There's actually code on here somewhere on how to read the file properly, someone else asked this already. 

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
  • 655 views
  • 0 likes
  • 2 in conversation