Hi There,
Just having a problem with SAS not recognising one of my variables whilst I am trying to encode a new variable.
Basically the code looks like:
if CTA_LAD=1 OR CTA_CX or CTA_RCA=1 then CTAPP=1;
else CTAPP=0;
However, SAS seems to be creating a new variable for CTA_CX filled with missing values. As far as I can see I am typing the exact variable name as it appears in my original datasheets and the SAS output.
It is not doing this for any of my other recoding steps.
Thanks in advance for your support!
Addit: there was a missing space in the name that I only saw on proc print!
But now I am having a different problem:
When I try:
DATA;
rename
'CTA(space)_CX'n=CTA_CX;
RUN;
It replaces CTA(space)_CX with all missing values and creates a new variable CTA_CX which is also populated with missing values.
Thanks!
Run a proc contents to see your variable names instead of labels. I'm not sure your condition is specified correctly, I think you want what's below.
if CTA_LAD=1 OR CTA_CX=1 or CTA_RCA=1 then CTAPP=1;
else CTAPP=0;
Thanks for the reply.
You're correct about that bit of code being incorrect, but the renaming step is where the error is occuring in that it is creating the new variable. I copied the exact title from a PROC PRINT statement and its not working. I guess I'll just edit the original spreadsheet and try again, would have been interesting to know why this was happening.
Cheers again!
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.