Hello,
I am a novice SAS user and would much appreciate any advice regarding this error:
proc transpose data=ewretdat out=ewretdat2 (rename = (_1=SELL _2=PORT2 _3=PORT3 _4=PORT4 _5=PORT5 _6=PORT6 _7=PORT7 _8=PORT8 _9=PORT9 _10=BUY)); by date; id momr; var ewret; run;
The warning indicates that Proc Transpose doesn't create a variable _1. May be your variable momr never has a value of 1 in your source data.
Run your Proc Transpose statement first without the rename and check what variable names you actually get.
If you have to run the transpose on a number of datasets where not all momr values will be present each time, here is another way to assign the variable names you want:
data ewretdat; input momr ewret date date9.;
format date date9.; cards; 1 1 01apr2017 2 1 01apr2017 1 2 1may2017 2 2 01may2017 ; proc format; value momr 1=SELL 2=PORT2 3=PORT3 4=PORT4 5=PORT5 6=PORT6 7=PORT7 8=PORT8 9=PORT9 10=BUY ; run; proc transpose data=ewretdat out=ewretdat2; by date; id momr; var ewret; format momr momr.; run;
Art, CEO, AnalystFinder.com
@art297: There is a much easier way. Use the PREFIX= option in PROC TRANSPOSE:
proc transpose data=ewretdat out=ewretdat2 prefix=PORT; by date; id momr; var ewret; run;
@art297 wrote:If you have to run the transpose on a number of datasets where not all momr values will be present each time, here is another way to assign the variable names you want:
data ewretdat; input momr ewret date date9.;
format date date9.; cards; 1 1 01apr2017 2 1 01apr2017 1 2 1may2017 2 2 01may2017 ; proc format; value momr 1=SELL 2=PORT2 3=PORT3 4=PORT4 5=PORT5 6=PORT6 7=PORT7 8=PORT8 9=PORT9 10=BUY ; run; proc transpose data=ewretdat out=ewretdat2; by date; id momr; var ewret; format momr momr.; run;Art, CEO, AnalystFinder.com
While the variables won't always exist, you can get rid of the warning pretty easily. Add this to your program:
options dkrocond=nowarn;
That won't add the missing variables, but it will get rid of the warning.
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.