BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

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?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

View solution in original post

16 REPLIES 16
Reeza
Super User
Are you sure? It looks like that error is for N=20, not 19?

Can you use the prefix instead?

data bigt;
set simt: ;
run;

Otherwise, I think you should run it with MPRINT on and post the full log.
jacksonan123
Lapis Lazuli | Level 10
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.


ballardw
Super User

@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
Lapis Lazuli | Level 10
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.







NOTE: There were 18 observations read from the data set WORK.SIMT19_1.

NOTE: There were 18 observations read from the data set WORK.SIMR19_1.

NOTE: The data set WORK.SIMFIN19_1 has 36 observations and 18 variables.

NOTE: DATA statement used (Total process time):

real time 0.00 seconds

cpu time 0.01 seconds





MLOGIC(BOOTR): %DO loop index variable J is now 2; loop will iterate
again.

SYMBOLGEN: Macro variable I resolves to 19

SYMBOLGEN: Macro variable J resolves to 2

MPRINT(BOOTR): DATA AREF19_2;

SYMBOLGEN: Macro variable I resolves to 19

SYMBOLGEN: Macro variable J resolves to 2

MPRINT(BOOTR): set ref19_2;

MPRINT(BOOTR): Treat='BREF';

MPRINT(BOOTR): run;




ballardw
Super User

@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.

 

 

Reeza
Super User

Any RSUBMITS in your code anywhere? Any chance you're mixing up local and server work spaces?

 

And no attachments either 😞

 

jacksonan123
Lapis Lazuli | Level 10
I am not sure. I tried this code which set all the data files at program's
end.

data simfin&i._&j;

set simt&i._&j simr&i._&j

%do i = 1 %to 19;

%do j = 1 %to 2;

;

%end;

%end;

run;



PROC EXPORT DATA=simfin&i._&j

OUTFILE= "/folders/myfolders/IMLSUBGEN/allfinal.csv"

DBMS=CSV REPLACE;





RUN;



%end;

%end;

%mend bootR;

%bootR;

Run;



It ran okay with 1 error:

NOTE: There were 18 observations read from the data set WORK.SIMT1_1.

NOTE: There were 18 observations read from the data set WORK.SIMR1_1.

NOTE: The data set WORK.SIMFIN1_1 has 36 observations and 16 variables.

NOTE: DATA statement used (Total process time):

real time 0.00 seconds

cpu time 0.00 seconds





MPRINT(BOOTR): PROC EXPORT DATA=simfin20_3 OUTFILE=
"/folders/myfolders/IMLSUBGEN/allfinal.csv" DBMS=CSV REPLACE;

MPRINT(BOOTR): ADLM;

MPRINT(BOOTR): RUN;

NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update
mode. Temporary parameter values will be saved to

WORK.PARMS.PARMS.SLIST.

ERROR: File WORK.SIMFIN20_3.DATA does not exist.

ERROR: Export unsuccessful. See SAS Log for details.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE EXPORT used (Total process time):

real time 0.05 seconds

cpu time 0.04 seconds



MPRINT(BOOTR): ;

527 run;

528

529

How should this error be interpreted and fixed?
Kurt_Bremser
Super User
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.

jacksonan123
Lapis Lazuli | Level 10
I can do that but how do I keep it connected to the current post?
novinosrin
Tourmaline | Level 20

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?

novinosrin
Tourmaline | Level 20

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

ballardw
Super User

@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
Lapis Lazuli | Level 10

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 1580 views
  • 4 likes
  • 5 in conversation