I am trying to breakdown data file into small files, with one of the variables as a part of the name for those files. To be specific, I have a bunch of Census tracts, plus other variables. I am reading them into the matrix, perform some operations and now would like to export the data out of the loop and save it as external data file, with census tract as a part of the name; this has to be done without breaking the loop or quitting IML as I am moving onto the next tract:
read i = first census tract;
append data from other matrix;
save out file as "rld_'census_tract' value";
read next census tract;
repeat;
I tried symput function but it requires using data null inside the IML which breaks the flow.
I don't know the solution in IML (or even if there is), but I'd suggest a different solution.
Write all of your matrices out to a single dataset (either by appending them all together or by appending to a single dataset as the loop progresses, whichever is easier), and append 'census tract' as one variable in that dataset. Then use a sas datastep to write them out to separate files afterwards. If you're talking about writing out to separate sas datasets, you can either use conditional logic or you can create a macro call to do it; if you are writing external files such as CSV or text file, you can use a filename variable (
filevar
option on thefile
statement) and write it out that way.This will be fairly efficient (in particular for the external file method) and doesn't require staying in IML.