I have a 19 subject study with two treatments so my files are named simt&i._&j where
i = 1 %to 19;
j= 1 %to 1;
When processing one treatment j=1. When I use the attached code I get the following error listed below the code.
/***********SET DATA SETS VIA A MACRO***************/
%macro combine;
data bigt;
set
%do i = 1 %to 19;
%do j= 1 %to 1;
simt&i._&j
%end;
%end;
;
run;
%mend;
%combine;
:ERROR: File WORK.SIMT20_2.DATA does not exist.
If I change the i to 18 it runs fine but I only get 18 subjects.
Can you tell me why I get the error when I use 19? How can I change the code to avoid this error?
@jacksonan123 wrote:
I have a 19 subject study with two treatments so my files are named simt&i._&j where
i = 1 %to 19;
j= 1 %to 1;When processing one treatment j=1. When I use the attached code I get the following error listed below the code.
/***********SET DATA SETS VIA A MACRO***************/ %macro combine; data bigt; set %do i = 1 %to 19; %do j= 1 %to 1; simt&i._&j %end; %end; ; run; %mend; %combine;
:ERROR: File WORK.SIMT20_2.DATA does not exist.
If I change the i to 18 it runs fine but I only get 18 subjects.
Can you tell me why I get the error when I use 19? How can I change the code to avoid this error?
I suspect that you need to copy from the LOG when you ran the code the actual macro definition used along with the error message(s). Paste the into a code box opened with the {I} icon.
The code you post above will not generate any entries ending in _2 or sim20. Which is why I am asking to show from log what you actually ran.
@jacksonan123 wrote:
The log was long so I added it as an attachment. However if it can be read
I will put the final lines in the E-mail. It said that the files did not
exist.
MLOGIC(COMBINE): %DO loop index variable I is now 20; loop will not iterate
again.
MPRINT(COMBINE): set simt1_1 simt2_1 simt3_1 simt4_1 simt5_1 simt6_1
simt7_1 simt8_1 simt9_1 simt10_1 simt11_1 simt12_1 simt13_1
simt14_1 simt15_1 simt16_1 simt17_1 simt18_1 simt19_1 ;
ERROR: File WORK.SIMT2_1.DATA does not exist.
ERROR: File WORK.SIMT3_1.DATA does not exist.
ERROR: File WORK.SIMT4_1.DATA does not exist.
ERROR: File WORK.SIMT5_1.DATA does not exist.
If none of your sets are found then perhaps you placed then in a library other than work and forgot to put the libname in the SET statement code?
Or haven't created the data sets yet?
Or something previous has failed so that this now has errors because the step(s) that should generate the SIMT data sets did not create the datasets:?
@jacksonan123 wrote:
When I try to export with this command:
PROC EXPORT DATA=simt&i._&j
OUTFILE= "/folders/myfolders/IMLSUBGEN/allfinal.csv"
DBMS=CSV REPLACE;
RUN;
and remove the set macro I get the log below which tells me that the files
are being written and to my knowledge I have not knowingly placed them into
a library as suggested or have not been created.
Yu stated that , "If none of your sets are found then perhaps you placed
then in a library other than work and forgot to put the libname in the SET
statement code?
Or haven't created the data sets yet?" The log would say they have been
created unless I am mis-interpreting the output.
And the relationship between your BOOTR macro and COMBINED? Sequence or order of code matters. Just because something exists at one time does not mean they exist earlier or later.
At the time you run your COMBINED macro the data sets do not exist from the error in the SET statement.
Try turning off SYMBOLGEN and MLOGIC so that only the MPRINT shows and there is less verbiage to run through. Then it may be more obvious what is happening where those sets are referenced when they don't exist.
Also if you are rerunning code something that did not exist in the first run because some code is slightly out of order might exist during a later run in the same session because the sets now exist from the previous attempt.
Any RSUBMITS in your code anywhere? Any chance you're mixing up local and server work spaces?
And no attachments either 😞
ERROR: File WORK.SIMFIN20_3.DATA does not exist.
Dataset WORK.SIMFIN20_3.DATA was never created.
Since you still haven't shown us your whole code and/or your whole log as requested, there's not much to diagnose.
Search your log for the string "WORK.SIMFIN20_3" to see where (or if) your dataset was created at all.
Use the "little running man" for code, and {i} for logs, as the main posting window scrambles the formatting; if you feel that the log is too big for inserting in the post, attach it as a text file.
Save your log to a file, rename it to a .txt extension, and attach it to a post. See the example here.
I don't know whether there is a need for the loop %do j=1 %to 1;
Doesn't make sense
%macro combine;
/*data bigt;*/
/* %put set */
%do i = 1 %to 19;
/* %do j= 1 %to 1;*/
%put simt&i._1 ;
%end;
/* %end;*/
;
run;
%mend;
%combine;
562 %macro combine;
563 /*data bigt;*/
564 /* %put set */
565 %do i = 1 %to 19;
566 /* %do j= 1 %to 1;*/
567 %put simt&i._1 ;
568 %end;
569 /* %end;*/
570 ;
571 run;
572 %mend;
573 %combine;
simt1_1
simt2_1
simt3_1
simt4_1
simt5_1
simt6_1
simt7_1
simt8_1
simt9_1
simt10_1
simt11_1
simt12_1
simt13_1
simt14_1
simt15_1
simt16_1
simt17_1
simt18_1
simt19_1
is this what you are expecting?
and keep the nested j indexed loop, works fine
574 %macro combine;
575 /*data bigt;*/
576 /* %put set */
577 %do i = 1 %to 19;
578 %do j= 1 %to 1;
579 %put simt&i._1 ;
580 %end;
581 %end;
582 ;
583 run;
584 %mend;
585 %combine;
simt1_1
simt2_1
simt3_1
simt4_1
simt5_1
simt6_1
simt7_1
simt8_1
simt9_1
simt10_1
simt11_1
simt12_1
simt13_1
simt14_1
simt15_1
simt16_1
simt17_1
simt18_1
simt19_1
@jacksonan123 wrote:
I have a 19 subject study with two treatments so my files are named simt&i._&j where
i = 1 %to 19;
j= 1 %to 1;When processing one treatment j=1. When I use the attached code I get the following error listed below the code.
/***********SET DATA SETS VIA A MACRO***************/ %macro combine; data bigt; set %do i = 1 %to 19; %do j= 1 %to 1; simt&i._&j %end; %end; ; run; %mend; %combine;
:ERROR: File WORK.SIMT20_2.DATA does not exist.
If I change the i to 18 it runs fine but I only get 18 subjects.
Can you tell me why I get the error when I use 19? How can I change the code to avoid this error?
I suspect that you need to copy from the LOG when you ran the code the actual macro definition used along with the error message(s). Paste the into a code box opened with the {I} icon.
The code you post above will not generate any entries ending in _2 or sim20. Which is why I am asking to show from log what you actually ran.
After thoroughly studying my log (suggested by several responders) and with the N 1 to 18 working I realized that I had mistakenly assigned subj1 as a variable in the data set which left me with N=18 instead of N=19 thus the error.
With that correction the code worked fine.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.