/*file name: gendat.sas */ /*purpose: generate correlated data to compare OLS and WLS */ /*Change printing page size to save paper*/ OPTIONS PS=60; /*You do not have to change the seeds. They are chosen to be negative numbers in this program so that initialization of the random number stream depends on the computer clock observations. Using this program, each of you should be able to get a different data set from anyone else. Positive seeds will generate the identical random number streams every time you run the program.*/ /*Define libname. You might change 'a:\' into any directory you like*/ LIBNAME SSD 'A:\'; data a; do id=1 to 40; b0=10+sqrt(1)*rannor(-1920803021); do j=1 to 4; e=0+sqrt(.5)*rannor(-9029019202); x=j; y=b0+1*x+e; output; end; end; run; /*delete some observatons to create imbalance*/ DATA b ; SET A; if id <= 10 then do; if j=2 then delete; if j=3 then delete; if j=4 then delete; end; if id>10 and id<=20 then do; if j=3 then delete; if j=4 then delete; end; if id>20 and id<=30 then do; if j=4 then delete; end; RUN; /*delete the unnecessary variables */ data c (drop=b0 e j); set b; run; /*Have a look at the data set. X is the indepent variable, Y is the response variable and id is the id variable. Each of the persons with id from 1 to 10 has 1 observation. Each of the persons with id from 11 to 20 has 2 observations. Each of the persons with id from 21 to 30 has 3 observations and each of the persons with id from 31 to 40 has 4 observations. */ PROC PRINT; RUN; /*Create a permanent SAS data set with filename 'C:\GENDAT.SD2'. 'SD2' is default by SAS. */ DATA SSD.GENDAT; SET c; RUN; QUIT; /*the end of the program*/