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?
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.
DLMSTR in the infile statement. Look it up under the INFILE documentation.
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 😕
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.
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.
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.