I have been working with a friend of mine in a breeding strategy simulation project using SAS (!!). I would rather use S+ or R for this type of simulation, but the only computer languages that we have in common with my friend were SAS and Fortran. The latter was just too much work compared to using a matrix language like Matlab, Python+Numpy, R or… SAS IML.
Programming data generation in SAS IML was not that difficult, but then we needed to:
- Save data,
- Run ASReml from inside SAS,
- Read the variance components from the .asr file and store them for further processing.
Running ASReml from SAS can be done using the
call system function call, but rather than calling ASReml directly, one calls a .bat file, allowing for more complex commands. Let’s say that
analysis.bat contains the following commands:
The first line calls ASReml, while the second one closes the DOS (or command) window. Then the .bat file can be called using something like:
SAS is very good at reading files with a clear format (like comma or space-separated values, as in the .sln or .yht files) but not that great at reading free-form files (like .asr files). I wrote this little bit of SAS code to read the .asr file, which is working fine — at least for the simple univariate analyses I have tested.
data asreml comps(keep = component value stderr);
infile dotasr dlm="%" missover;
length string $ 100;
* String with the name of variance components to read;
comps = 'Variance Block treeID';
id = scan(string, 1, " ");
pos = index(comps, strip(id));
if index(comps, strip(id)) > 0 then do;
component = id;
value = scan(string, 5," ");
stderr = scan(string, 6," ");
I have also some instructions for running simulations using Python.