BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abuanuazu
Fluorite | Level 6

Objective:

I was interested to create a new variable "treat" , to read the data,  and provide information about cancer patient frequency of those taking chemotherapy or not.

 

 

data chemo1;
  set adph;
 
  select(Chemotherapy);
    when(0) treat="No chemo";
    when (1) treat="Yes Chemo";
    otherwise;
    end;

run;

proc freq data=chemo1;
  table treat/chisq;run;

 

After I ran the above code, produce all the data as missing with the new variable "treat". I need your help.Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Awesome. You can list multiple conditions in your WHEN statement. 

 

Data chemo;
  set adph;
select (Chemotherapy);
   when('chemoth', 'recoome') chemo='Yes chemo';
   otherwise chemo='No chemo';
  end;
run;

View solution in original post

4 REPLIES 4
Reeza
Super User

Without data we can't really comment. But you can change your proc freq to help diagnose the issue. 

 

Post the results from the following code:

 

proc freq data=chemo1;
  table chemotherapy*treat/chisq missing list;
run;

 

abuanuazu
Fluorite | Level 6

Dear Reeza,

 

Thank you for prompt response. Still I need more assistance. As per your code, the result attached. It picks all the patients as "No chemo". Please find here is attached the sub-variables under Chemotherapy and the data type is boolean as 1 or 0.Thank you again.

 

Abuanuazu

abuanuazu
Fluorite | Level 6

Dear All,

 

Thank you for your help. Finally, I got the solution to the problem

 

Data chemo;

  set adph;

select (Chemotherapy);
   when('"chemoth') chemo='Yes chemo';
   when('"recomme') chemo='Yes chemo';
   otherwise chemo='No chemo';
  end;

 

 

Reeza
Super User

Awesome. You can list multiple conditions in your WHEN statement. 

 

Data chemo;
  set adph;
select (Chemotherapy);
   when('chemoth', 'recoome') chemo='Yes chemo';
   otherwise chemo='No chemo';
  end;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 1576 views
  • 2 likes
  • 2 in conversation