Help using Base SAS procedures

Not is null in a data step code

Accepted Solution Solved
Reply
Regular Contributor
Posts: 186
Accepted Solution

Not is null in a data step code

Hi,

I would like to have a column with concatenated values if one of the cell used to concatenate is not null.

How do I do the following?

data icoplib.icop_alerts4 (drop=CRITERIA_VALUE_in);

set icoplib.icop_alerts3 (rename=(CRITERIA_VALUE=CRITERIA_VALUE_in));

if risk_level not is null then do;

criteria_value = trim(criteria_value_in) || ' - ' ||trim(risk_level);

end;

else do;

criteria_value=trim(criteria_value_in);

end;

run;

Thank you for your help and time.


Accepted Solutions
Solution
‎08-19-2013 11:04 AM
Super User
Posts: 10,466

Re: Not is null in a data step code

In data step

if not missing(risk_level) then do;

You might not need the if though.

The CATX function truncates blanks and places specified delimiter between strings.

 

data _null_;

risk_level='';

criteria_value_in = 'criteria';

criteria_value= catx('-',criteria_value_in,risk_level);

put criteria_value;

run;

View solution in original post


All Replies
Solution
‎08-19-2013 11:04 AM
Super User
Posts: 10,466

Re: Not is null in a data step code

In data step

if not missing(risk_level) then do;

You might not need the if though.

The CATX function truncates blanks and places specified delimiter between strings.

 

data _null_;

risk_level='';

criteria_value_in = 'criteria';

criteria_value= catx('-',criteria_value_in,risk_level);

put criteria_value;

run;

Regular Contributor
Posts: 186

Re: Not is null in a data step code

Works like a charm.

Thank you very much.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 396 views
  • 0 likes
  • 2 in conversation