BookmarkSubscribeRSS Feed
Kiko
Fluorite | Level 6

Hi! 

 

I am not sure if this is the right place to ask this type of question, but here I go. So currently, the SAS program I use generate a random sample of the event/outcome of interest for review. The process is quite manual, because once the review is complete, I have to update the status of those charts (e.g. review requested, review complete etc.) manually and make sure that they are excluded from the sample pool for next review. Also, I change LocID for a specific site.

 

Here’s the sample code I currently use. PT is the name of one of the domains where the data is getting pulled from for this particular event/outcome (A).

 

data study; set study1.PT (keep=subjID DOV ptterm LocID ptnum visit adddat);

where visit='A' and locID in (1 18 35 60 25 45 77);

if subjID in  (         ) then review='Review Done    ' ; else

if subjID in  (         ) then review='Review Requested    '; else

if ptnum  in  (         ) then review='Review Done     '; else

if ptnum  in  (         ) then review='New info since last review'; else

                               review='Review Not Requested';

label review='Review Status';

run;

 

proc print data=study noobs label;

            var subjID ptnum DOV ptterm review; where locID=77; run;

 

proc surveyselect data=study method=srs out=out seed=1025 n=5;

      where locID=77 and review not in ('Done' 'Requested'); run;

 

proc print noobs label data=study; var subjID ptnum DOV ptterm; run;

 

I wonder if there is a way to make this step/process less manual, or to make it more efficient in general. Macro is the first thing that came to mind, but not sure about how to.

 

Any comments/feedback would be greatly appreciated!

1 REPLY 1
ballardw
Super User

@Kiko wrote:

Hi! 

 

I am not sure if this is the right place to ask this type of question, but here I go. So currently, the SAS program I use generate a random sample of the event/outcome of interest for review. The process is quite manual, because once the review is complete, I have to update the status of those charts (e.g. review requested, review complete etc.) manually and make sure that they are excluded from the sample pool for next review. Also, I change LocID for a specific site.

Does the review process generate any output data set? With the Subjid? Is Subjid duplicated in your data set, possibly keeping track of a history, or is there only one record/status at a time for the subject?

 

If the subject doesn't appear in more than one LOCID then that really doesn't have much impact.

The question sort of becomes dependent on what you have. If your review process doesn't generate any data sets then somewhere some data entry will have to be done manually.

If you keep your OUT data set from surveyselect, likely with a better name, then you might be able to edit that in VIEWTABLE and use that to update your main study data set. But  I'm not sure at what point you want to do that because you don't show any attempt at that.

 

I know that I do not see the logic of selecting based on multiple LOCID in the DATA STUDY step but then only using a single LOCID in the Proc Surveyselect code. If you are making multiple calls to surveyselect then likely sort the data set study by LOCID and then use LOCID as a STRATA variable. If all of the LOCID have the same sample size requirement that is very minor change to the code. If you need different sample sizes per LOCID then the sampsize parameter in surveyselect will take a list of values example:

 

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

proc surveyselect data=work.class out=work.sampled
  sampsize=(4 3 2 3 2 2)   selectall
  ;
strata age;
run;

Strata does require the data to be sorted. The Selectall option will select all of the available records if the strata does not have enough to fulfill the request. In this example there are only 2 age=11 and 1 age=16. The list in SAMPSIZE matches the sample request size to the sorted values of the Strata variable so requested 4 age=11 and 2 for age=16 so we get notes in the log about that but the data is as likely needed given the input.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 611 views
  • 0 likes
  • 2 in conversation