BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Analyticguru_09
Fluorite | Level 6

I'm trying to create a random dataset with 1000 observations and 3 variables(Employee_id, sex, age). I want the employee_id to be in the range (5213 to 9899), sex (as male,female or unknown) and age in between 25 to 75. Is there any function/sas proc thru which i can achieve this? I want the employee id to be random rather than consecutive.Thanks for help

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

A simple way :

 

proc format;
value sexFmt
     1 = "male"
     2 = "female"
     3 = "unknown";
run;

data test;
format sex sexFmt.;
call streaminit(6875687);
do empId = 5213 to 9899;
     sex = rand("TABLE",0.4,0.4);
     age = 25 + floor(51*rand("UNIFORM"));
     output;
     end;
run;

proc surveyselect data=test out=want n=1000 noprint; run;

PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

A simple way :

 

proc format;
value sexFmt
     1 = "male"
     2 = "female"
     3 = "unknown";
run;

data test;
format sex sexFmt.;
call streaminit(6875687);
do empId = 5213 to 9899;
     sex = rand("TABLE",0.4,0.4);
     age = 25 + floor(51*rand("UNIFORM"));
     output;
     end;
run;

proc surveyselect data=test out=want n=1000 noprint; run;

PG

PG
Analyticguru_09
Fluorite | Level 6

PGSTATS - Thanks a lot. I learned something new about the streaminit and rand table option.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 2 replies
  • 2833 views
  • 0 likes
  • 2 in conversation