BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
beverlyobeng
Calcite | Level 5

I keep getting this error message with the code detailed below:

 

%LET NAME= sup1_Fac_pat_demo_chisq;
WARNING: Extraneous text on %MEND statement ignored for macro definition EASY4.
10679 %LET NAMES= sup0_Fac_pat_demo_chisq;
10680 data compare_vs_nvs;
10681 set %easy3 %easy4;
MPRINT(EASY3): data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);
ERROR: File WORK.DATA.DATA does not exist.
MPRINT(EASY3): set sup1_Fac_pat_demo2;
MPRINT(EASY3): status="VS at Elmhurst Hospital Center";
MPRINT(EASY3): run;

 

CODE:  

 


*VS/not VS;
%LET NAME= sup1_Fac_pat_demo_chisq;
%LET NAMES= sup0_Fac_pat_demo_chisq;


%macro easy3;
data &NAME (keep = sex newrace2 livingage_new&year. risk status); set sup1_Fac_pat_demo2;
status="VS at &Facility_X"; run;
%mend;

 

%macro easy4;
data &NAMES (keep = sex newrace2 livingage_new&year. risk status); set sup0_Fac_pat_demo2;
status="not VS at &Facility_X"; run;
%mend

 

%LET NAME= sup1_Fac_pat_demo_chisq;
%LET NAMES= sup0_Fac_pat_demo_chisq;
data compare_vs_nvs;
set %easy3 %easy4;
run;

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

From your log entry:

 set %easy3 %easy4;
MPRINT(EASY3): data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);
ERROR: File WORK.DATA.DATA does not exist.

 

 set %easy3 %easy4;

Generates this code (at least in part from %easy3):

set data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);

Which says that there should be a dataset name data somewhere to read. That is the proximate cause of the error message because you do not currently have a data set named Data in your default work library.

Then the second data set sup1_Fac_pat_demo_chisq is expected to be read with the listed variables kept. The remaining statements from %easy3 are syntactically correct but likely not what you meant to do.

View solution in original post

9 REPLIES 9
Astounding
PROC Star

There's a missing semicolon after:

 

%mend

 

We've all done that at one time or another.

 

You should add OPTIONS MPRINT;

 

That way, you can see the code that is generated.  You would realize that this is not correct:

 

set data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);

 

You don't have a data set named "data" to bring in.

beverlyobeng
Calcite | Level 5

I still get the same error messages

Astounding
PROC Star

Yes, you will still get the same errors.  (The Warning should be gone, however.)

 

These changes don't fix the errors.  They merely let you examine the log to see the flaws in your program.  They are many, and substantial, and will force you to learn more about macro language to correct them.  So the first lesson is this.  You have to read the log and try to see why the errors are occurring.  The second is this.  Macro language is not processing your data.  It is building a program.  So when you code this:

 

set %easy3 %easy4;

 

Your expectations of what should happen are not correct.  %EASY3 does not create a data set that becomes part of the SET statement.  Instead, %EASY3 generates SAS code that adds to the SET statement.  So does %EASY4.  So this SET statement adds the generated text, and becomes:

 

set

data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new&year. risk status); set sup1_Fac_pat_demo2;
status="VS at &Facility_X"; run;

data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new&year. risk status); set sup0_Fac_pat_demo2;
status="not VS at &Facility_X"; run;

 

Clearly, this is not your intention as to what your SET statement should look like, nor is it a working program.  But seeing this in your log should at least guide you into making changes.

LinusH
Tourmaline | Level 20
Show the new log.
Data never sleeps
beverlyobeng
Calcite | Level 5
data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);
ERROR: File WORK.DATA.DATA does not exist.
MPRINT(EASY3): set sup1_Fac_pat_demo2;
MPRINT(EASY3): status="VS at Elmhurst Hospital Center";
MPRINT(EASY3): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.COMPARE_VS_NVS may be incomplete. When this step was stopped there were
0 observations and 24 variables.
WARNING: Data set WORK.COMPARE_VS_NVS was not replaced because this step was stopped.
LinusH
Tourmaline | Level 20
The full log please so we can see the code.
Data never sleeps
beverlyobeng
Calcite | Level 5


10745
10746 %macro easy3;
10747 data &NAME (keep = sex newrace2 livingage_new&year. risk status); set sup1_Fac_pat_demo2;
10748 status="VS at &Facility_X"; run;*/Bright:641;
10749 %mend;
10750
10751 %macro easy4;
10752 data &NAMES (keep = sex newrace2 livingage_new&year. risk status); set sup0_Fac_pat_demo2;
10753 status="not VS at &Facility_X"; run;*/Bright:248;
10754 %mend;
10755
10756 %LET NAME= sup1_Fac_pat_demo_chisq;
10757 %LET NAMES= sup0_Fac_pat_demo_chisq;
10758 data compare_vs_nvs;
10759 set %easy3 %easy4;
MPRINT(EASY3): data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);
ERROR: File WORK.DATA.DATA does not exist.
MPRINT(EASY3): set sup1_Fac_pat_demo2;
MPRINT(EASY3): status="VS at Elmhurst Hospital Center";
MPRINT(EASY3): run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.COMPARE_VS_NVS may be incomplete. When this step was stopped there were
0 observations and 24 variables.
WARNING: Data set WORK.COMPARE_VS_NVS was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds


MPRINT(EASY3): */Bright:641;
MPRINT(EASY4): data sup0_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);
MPRINT(EASY4): set sup0_Fac_pat_demo2;
MPRINT(EASY4): status="not VS at Elmhurst Hospital Center";
MPRINT(EASY4): run;

NOTE: There were 84 observations read from the data set WORK.SUP0_FAC_PAT_DEMO2.
NOTE: The data set WORK.SUP0_FAC_PAT_DEMO_CHISQ has 84 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

Astounding
PROC Star

Two questions, at this point, concerning SET %EASY3 %EASY4;:

 

(1) Can you see in the log where the first word after "SET" is "DATA" which is not the name of an existing data set?

(2) What are you expecting SET %EASY3 %EASY4; to actually do?

ballardw
Super User

From your log entry:

 set %easy3 %easy4;
MPRINT(EASY3): data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);
ERROR: File WORK.DATA.DATA does not exist.

 

 set %easy3 %easy4;

Generates this code (at least in part from %easy3):

set data sup1_Fac_pat_demo_chisq (keep = sex newrace2 livingage_new2014 risk status);

Which says that there should be a dataset name data somewhere to read. That is the proximate cause of the error message because you do not currently have a data set named Data in your default work library.

Then the second data set sup1_Fac_pat_demo_chisq is expected to be read with the listed variables kept. The remaining statements from %easy3 are syntactically correct but likely not what you meant to do.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 17846 views
  • 0 likes
  • 4 in conversation