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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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