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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1063 views
  • 0 likes
  • 2 in conversation