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

Hello, 

 

I am having difficultly achieving the following objective when given an excel data file. I have started the code below, but cannot produce an output. 

 

Objective using Macros: 

From each of the 5 clinics (inst_num) randomly select 5 AML patients, 10 CML patients, 20 ALL patients, and 5 CLL patients (leu_type). If there are less than 5 AML patients then select all of them, if there are less than 10 CML patients then select all of them, if there are less than 20 ALL patients then select all of them, and if there are 5 CLL patients then select all of them. 

Then find cross-tabulation of Leu_type and inst_num. Additionally, print final dataset. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Is this a homework assignment? Because this thread works on almost the exact same data and the exact same variable names.

https://communities.sas.com/t5/Base-SAS-Programming/How-to-filter-a-dataset-with-an-IF-condition/m-p...

 

But, you don't need macros to do this. Assign a random number to each group, sort and then take the top 5 (or top 10, or top 20) etc to randomly select.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

Is this a homework assignment? Because this thread works on almost the exact same data and the exact same variable names.

https://communities.sas.com/t5/Base-SAS-Programming/How-to-filter-a-dataset-with-an-IF-condition/m-p...

 

But, you don't need macros to do this. Assign a random number to each group, sort and then take the top 5 (or top 10, or top 20) etc to randomly select.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 581 views
  • 2 likes
  • 2 in conversation