BookmarkSubscribeRSS Feed
sarabear
Calcite | Level 5

I have a data set with an ID column, and a primary reviewer column. I've randomly assigned a second reviewer for every observation. Now what I need is a way to print out 50% of the observations from every primary reviewer. So for example if Anna is the primary reviewer for 10 ID's- I want to choose 5 of those IDs at random and print those rows. (If she has 11, then I'd want to round to the nearest whole number, so 6 in this case)

 

The basic framework is something like 

 

proc print data=mydata;

     where nobs=%randbetween(1, _n_(primary_reviewer)*.5);

quit;

 

Obviously there's some issues with the syntax and it doesn't run, so that's what I need some help with. The randbetween macro is something I've built already(looks like the below)

 

%macro RandBetween(min, max);
     (&min + floor((1+&max-&min)*rand("uniform")))
%mend;

 

 

10 REPLIES 10
ballardw
Super User

If this were my project I'd be very tempted to 1) sort the data by the primary reviewer and 2) use proc surveyselect with a samprate of 50 and use the primary reviewer variable as a STRATA variable.

the output data set would contain some probability of selection and weighting variables for printing you could drop those variables and perhaps use BY group processing.

 

A rough example using SAShelp.class data set:

proc sort data=sashelp.class out=work.class;
by sex;
run;

proc surveyselect data=work.class out=work.sel
   samprate=.5;
   strata sex;
run;
sarabear
Calcite | Level 5

Awesome! I'm having an issue with surveyselect though(I'm not sure if my version of SAS supports that procedure)-do you know of any workarounds?

Reeza
Super User

@sarabear wrote:

Awesome! I'm having an issue with surveyselect though(I'm not sure if my version of SAS supports that procedure)-do you know of any workarounds?


What's the issue? 

If you don't have SURVEYSELECT you don't have SAS/STAT which would be really really rare.

sarabear
Calcite | Level 5

When I try to use proc surveyselect, I get an error that says "Procedure surveyselect not found"

Reeza
Super User

What version of SAS are you using?

 

Run the following and post back - but remove your site number:

 

proc product_status;run;

proc setinit;run;
sarabear
Calcite | Level 5

It's SAS 9.4. This is what the Log says

 

proc product_status;run;

 

For Base SAS Software ...
Custom version information: 9.4_M4
Image version information: 9.04.01M4P110916
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M4

 

proc setinit;run;

 

Original site validation data
Current version: 9.04.01M4P110916

Product expiration dates:
---Base SAS Software
30DEC2017
---SAS/STAT
30DEC2017
---SAS/GRAPH
30DEC2017
---SAS/OR
30DEC2017
---SAS/GIS
30DEC2017
---SAS/Secure 168-bit
30DEC2017
---SAS/Secure Windows
30DEC2017
---SAS Enterprise Guide
30DEC2017
---OR OPT
30DEC2017
---OR PRS
30DEC2017
---OR IVS
30DEC2017
---OR LSO
30DEC2017
---SAS/ACCESS Interface to PC Files
30DEC2017
---SAS/ACCESS Interface to ODBC
30DEC2017
---SAS/ACCESS Interface to OLE DB
30DEC2017
---SAS/ACCESS Interface to Teradata
30DEC2017
---SAS Workspace Server for Local Access
30DEC2017
---High Performance Suite
30DEC2017

 

Reeza
Super User

So you have it licensed but not installed so your installation wasn't done correctly. 

 

---SAS/STAT
30DEC2017

 

Note that this means you can't run any regression or stat procs, so it's possible it's how you're supposed to be set up but I'd question it for sure. 

ballardw
Super User

You are licensed for SAS/Stat (the proc setinit output) but someone didn't install it (not in proc product_status output).

 

I would discuss with your SAS Admin, or whoever installs the software, why that choice was made. I can see not having things like the Access to Teradata if your work doesn't require you to access that database but SAS/Stat is such a main piece of functionality the choice not to install it boggles my mind.

sarabear
Calcite | Level 5

OK-I'd thought it was an issue of installation. I'll check it out. Thanks!!

art297
Opal | Level 21

Surprised that no one mentioned it .. ALL of your SAS licenses have expired!

 

Art, CEO, AnalystFinder.com

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 646 views
  • 5 likes
  • 4 in conversation