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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 714 views
  • 2 likes
  • 2 in conversation