Background: I am conducting a sensitivity analysis where I am looping over combinations of two parameters A and B, where A=1,2 and B=1 to 9. I have saved down datasets for each of the 18 combinations of the two parameter values and I now would like to write a macro the generate summary statistics, by group, for 6 output variables I am interested in.
Problem: If I limit B to B=1 to 8 I get the 16 desired output datasets, however if I loop over B=1 to 9 I inexplicably get 21 output datasets, where the the output for the output for some iterations is duplicated, and trying to open the duplicates produces an error: "Cannot open dataset, file does not exist".
Although I do ultimately get the desired output, there must be something going wrong to produce the additional duplicate datasets.
Example code:
data data; input group $ var1-var6; datalines; group1 1 2 3 4 5 6 group2 7 8 9 10 11 12 ; run; %macro example; %do i = 1 %to 2; %do j = 1 %to 9; %let case = A&i._B&j.; data case_A&i._B&j.; set data; case = "&case."; run; %end; %end; %mend; %example
Any help would be greatly appreciated.
I doubt you create additional tables, check your log to verify. If not, then it looks like a display problem by the SAS client. In this case, you should contact SAS tech support.
I reran your code without any duplicates and I didn't find any duplicate datasets as you have mentioned. see it below. ( I executed it on SAS On Demand for Academics)
I have attached the log.
Needless to say that filesystems do not allow files of exactly the same name.
> Needless to say that filesystems do not allow files of exactly the same name.
I wonder what SAS sees if you have identical names but different cases under Linux/Unix. Like:
test.sas7bdat
Test.sas7bdat
SAS names are supposed to be lower case, so does SAS ignore the other files?
> For example test and Test are not the same.
Exactly. Hence my question.
At least with 9.4M7 on AIX and EG 7.15, only .sas7bdat files in all lowercase will appear in the library list.
But IIRC, there was a time when SAS would list all files with extension .sas7bdat as datasets (including those that had a capital letter before the extension), but would have trouble opening those that were not all lowercase.
Thanks for this. I did check the log and only 18 datasets were recorded as having been generated which added even more to my confusion. I forgot to mention this in my post, but it sounds like you are correct in that is is most likely a display problem.
As has been mentioned UNIX filesystems are case sensitive. So a file named CASE_A2_B9.sas7bdat is not the same file as one named case_a2_b9.sas7bdat.
SAS on unix will only use lowercase letters in the names of files used to store SAS datasets. So if you run this program:
data copy;
set sasuser.CASE_A2_B9;
run;
It will look for a file name case_a2_b9.sas7bdat in the directory pointed to by the SASUSER libref.
Using a quoted physical name to reference the dataset in your SAS code will not help. If you write code like:
data copy;
set "~/sasuser/CASE_A2_B9.sas7bdat";
run;
Under the hood SAS will create a new libref pointing to the ~/sasuser/ directory and reference the dataset the same way as if you had use two level name to begin with.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.