Hi guys!
I believe this question is already answered somewhere but I have spent last 2 hours finding elegant solution for this problem.
Imagine data set with for example 200 individuals and every individual has 40000 variables (genotypes).
ID | Var_1 | Var_2 | Var_3 | Var_... | Var_40000 |
---|---|---|---|---|---|
1 | A | A | B | ... | C |
2 | A | C | A | ... | A |
3 | B | A | A | ... | B |
... | ... | ... | ... | ... | ... |
200 | B | B | C | ... | B |
I want to keep all individuals but would like to randomly select 1000 variables (genotypes).
Ok, I can do proc transpose, then randomly select and transpose back, but sometimes I have 1000000 variables and transposing is really lost of time.
Selection of variables by list would be awesome, as well direct selection based on some random function.
I believe first way is more likable and I would be very happy if someone could give a hand with this one!
Thanks!
OK, that works but can you give me a hint about last step which would be having heart data only with this three variables?
Thanks!
sorry! I got it! I just copy paste note to data step!
Sunday afternoon...
Thanks!
data randomvars;
set sashelp.heart(keep=&keepvars);
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.