BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gaurav9839
Calcite | Level 5

Hi ,

 
I am facing the below problem while creating the dummy variable for the variable age_restriction
 
1- The variable is a character variable and contains 9 records (3,4,34,35,45,3U,4U and 5U)....
2-when i try to create the dummy variable it does not take the 3 as character variable and assumes it as numeric variable.
 
3- The code which i use for creating dummy variable is  below 
if age_restriction='3' then Age_R1=1;  else Age_R1=0;
 
i always get the value of Age_R1  =0 even though if age_restriction contains 3 as its value .
 
 
 
 
can you please help me on this error 
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You most probably have an alignment problem (the '3' is not the first character in age_restriction).

Use the left() function to left-align the variable before checking for its contents.

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

You most probably have an alignment problem (the '3' is not the first character in age_restriction).

Use the left() function to left-align the variable before checking for its contents.

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
  • 1 reply
  • 674 views
  • 0 likes
  • 2 in conversation