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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1083 views
  • 0 likes
  • 2 in conversation