BookmarkSubscribeRSS Feed
RahulM
Fluorite | Level 6

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!

4 REPLIES 4
RahulM
Fluorite | Level 6

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!

LinusH
Tourmaline | Level 20
Ig seems easier to start over than trying to repair something you are not really sure about.
I think that you are missing a =1 in your initial code?
Check your input data set carefully so you match variable names, data types and values.
Data never sleeps
Reeza
Super User

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;

 

 

RahulM
Fluorite | Level 6

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!

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
  • 4 replies
  • 1318 views
  • 0 likes
  • 3 in conversation