Printing a set of observations

Reply
Occasional Contributor
Posts: 5

Printing a set of observations

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;

 

 

Super User
Posts: 13,508

Re: Printing a set of observations

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;
Occasional Contributor
Posts: 5

Re: Printing a set of observations

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?

Super User
Posts: 23,683

Re: Printing a set of observations


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.

Occasional Contributor
Posts: 5

Re: Printing a set of observations

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

Super User
Posts: 23,683

Re: Printing a set of observations

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;
Occasional Contributor
Posts: 5

Re: Printing a set of observations

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

 

Super User
Posts: 23,683

Re: Printing a set of observations

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. 

Super User
Posts: 13,508

Re: Printing a set of observations

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.

Occasional Contributor
Posts: 5

Re: Printing a set of observations

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

PROC Star
Posts: 8,163

Re: Printing a set of observations

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

 

Art, CEO, AnalystFinder.com

 

Ask a Question
Discussion stats
  • 10 replies
  • 173 views
  • 5 likes
  • 4 in conversation