BookmarkSubscribeRSS Feed
Nasya
Obsidian | Level 7

Hi,

 

I am trying to convert numeric to character value for one of the variables, but the missing values are taking the values.

Can some one suggest a way that the missing values are displayed as missing value or correct me what I am missing in the code?

Thanks in advance.

 

Regards,

Nasya

*------------------------------------------------------------------------------*;
* Screener data set
*------------------------------------------------------------------------------*;
data screener (keep=subject age misd dispos);
      set pdata.screener;
       by subject;
run;

/*Sort the data*/
proc sort data= screener;
      by subject;
run;


data screenerfinal;
    set screener;
    attrib TEST length=$200; /*Convert numeric to character and new variable is assigned*/

   if dispos eq 6 then delete;/*Did not qualify*/

   misd_=put(misd, best.);

   if misd le 5 then TEST = ' Normal Level';
   else if misd > 5 then TEST = ' Low Level';
   else if misd eq . then TEST= ' '; 

    keep subject age misd test dispos;

run;


proc sort data= screenerfinal;
    by subject;
run;
1 REPLY 1
Kurt_Bremser
Super User

First you create a dataset with "by subject", which only works if the source is already sorted by subject, so the following sort serves no purpose.

 

Then you create character variable misd_, but never use it, and discard it immediately.

Have you inspected misd for its values?

 

Please post some example data for dataset screener, and tell us what you expect as a result for each observation. Use a data step with datalines to post example data in a usable way.

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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