Hi,
I would like to know how to store the number of records from a table in a variable and then based on that number select a random sample that is 10% of the size of the total number of records.
Here is what I came up with so far. My source table is cq_alert.closed_alert_cust :
data _NULL_;
if 0 then set cq_alert.closed_alert_cust nobs=n;
call symput('nrows',trim(left(put(n,8.))));
stop;
run;
%put nobs= int(&nrows/10); /* I'm trying to store 10% of my total number of records in variable nobs */
To illustrate this better, if my source table had 100 records, I would like to create a table with 10 random records from it.
Thank you for your help and time.
Just use RATE=.1 with survelselect.
Just use RATE=.1 with survelselect.
Thank you very much for the quick reply.
For the seconds part of my question :
Lets says I have this :
data _NULL_;
if 0 then set cq_alert.closed_alert_cust nobs=n;
call symput('nrows',trim(left(put(n,8.))));
stop;
run;
%put nobs= int(&nrows/10);
How do I use the variable nobs in a normal data procedure?
You could create a macro variable NOBS with %LET or you could create the variable in your data step and use it in code as &nobs.
Exactly what I needed.
Thank you very much for your help and time!
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.