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!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.