Hi,
This is driving me crazy as, this is too simple, but I may be too tired to see what is wrong.
In the code below, I have a snippet from a data step. When "LnMonthsToFinalStepCount " is missing, then instead of "Step_indicator = 'Never Step', I keep getting 'Finished Stepping'. What am I missing?
Thank you for your help!
Code:
length Step_Indicator $20;
if LnMonthsToFinalStepCount >= 0 then
Step_Indicator = 'Currently Stepping';
else if LnMonthsToFinalStepCount < 0 then
Step_Indicator = 'Finished Stepping';
else
Step_Indicator = 'Never Step';
in sas sort sequence . (missing) is smaller than 0, that's the reason
therefore when LnMonthsToFinalStepCount is missing the statement if LnMonthsToFinalStepCount < 0 evaluates to true
in sas sort sequence . (missing) is smaller than 0, that's the reason
therefore when LnMonthsToFinalStepCount is missing the statement if LnMonthsToFinalStepCount < 0 evaluates to true
if you want else statement to execute, you would have to change the code to
Code:
length Step_Indicator $20;
if LnMonthsToFinalStepCount >= 0 then
Step_Indicator = 'Currently Stepping';
else if not missing(LnMonthsToFinalStepCount ) and LnMonthsToFinalStepCount < 0 and then
Step_Indicator = 'Finished Stepping';
else
Step_Indicator = 'Never Step';
@novinosrin wrote:
if you want else statement to execute, you would have to change the code to
Code:
length Step_Indicator $20;
if LnMonthsToFinalStepCount >= 0 then
Step_Indicator = 'Currently Stepping';
else if not missing(LnMonthsToFinalStepCount ) and LnMonthsToFinalStepCount < 0 and then
Step_Indicator = 'Finished Stepping';
else
Step_Indicator = 'Never Step';
Shorter
if LnMonthsToFinalStepCount >= 0 then
Step_Indicator = 'Currently Stepping';
else if . < LnMonthsToFinalStepCount < 0 then
Step_Indicator = 'Finished Stepping';
else
Step_Indicator = 'Never Step';
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.