BookmarkSubscribeRSS Feed
Satori
Quartz | Level 8

Below is my code:

 

libname bvd '/data/bvd';
option ls=180 ps=500;

%macro nn(y); %do;

%macro n(a,b); %do j=1 %to &b;
%if &a=d %then %do;
proc import datafile='/data/bvd/xlsx/20&y_&j.xlsx' out=b&y_&j dbms=xlsx replace;
data &a&y; length BVDID $20. CNAME $50.; set b&y_1-b&y_&j; Source="D";
%end;

%if &a=o %then %do;
proc import datafile='/data/bvd/xlsx/&y_&j.xlsx' out=b&y_&j dbms=xlsx replace;
data &a&y; length BVDID $20. CNAME $50.; set b&y_1-b&y_&j; Source="O";
%end;

data b&y; set d&y o&y; XASSTS=max(ASSTS,SHFU); XREV=max(OPRE,SALE); XEMPL=EMPL; drop ASSTS SHFU OPRE SALE; %end; %mend; %if &y=19 %then %do; %n(d,7); %n(o,8); %end; %if &y=20 %then %do; %n(d,11); %n(o,7); %end; %if &y=21 %then %do; %n(o,14); %end; %if &y=22 %then %do; %n(o,26); %end; data temp; set b&y; retain _CNAME; if CNAME ne '' then _CNAME=CNAME; if CNAME eq '' then CNAME=_CNAME; drop _CNAME; proc sort; by CNAME; data bvd.b&y; set temp; by CNAME; retain _BVDID _XASSTS _XEMPL _SIC1 _SIC2 _XREV; if not last.CNAME then do; if BVDID ne '' then _BVDID=BVDID; if XASSTS ne . then _XASSTS=XASSTS; if SIC1 ne . then _SIC1=SIC1; if SIC2 ne . then _SIC2=SIC2; if XEMPL ne . then _XEMPL=XEMPL; if XREV ne . then _XREV=XREV; end; if not first.CNAME then do; if BVDID eq '' then BVDID= _BVDID; if XASSTS eq . then XASSTS=_XASSTS; if SIC1 eq . then SIC1=_SIC1; if SIC2 eq . then SIC2=_SIC2; if XEMPL eq . then XEMPL=_XEMPL; if XREV eq . then XREV=_XREV; end; drop _:; %end; %mend; %nn(19); %nn(20); %nn(21); %nn(22);

 

And this is the error:

 

51         %nn(19);
WARNING: Apparent symbolic reference Y_ not resolved.
WARNING: Apparent symbolic reference Y_ not resolved.
NOTE 137-205: Line generated by the invoked macro "N".
51          proc import datafile='/data/bvd/xlsx/20&y_&j.xlsx' out=b&y_&j dbms=xlsx replace; data &a&y; length BVDID $20. CNAME $50.; set b&y_1-b&y_&j; Source="D";
                                                                    _
                                                                    22
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATAFILE, DATATABLE, DBMS, DEBUG, FILE, OUT, REPLACE, TABLE, _DEBUG_.  

NOTE: Line generated by the invoked macro "N".
51          proc import datafile='/data/bvd/xlsx/20&y_&j.xlsx' out=b&y_&j dbms=xlsx replace; data &a&y; length BVDID $20. CNAME $50.; set b&y_1-b&y_&j; Source="D";
                                                                    _
                                                                    200
ERROR 200-322: The symbol is not recognized and will be ignored.

 

 

I don't understand why this doesn't work.

 

My objective is to run the macro nn(y) four times whereby y takes the values 19,20,21,22. The macro nn should activate the macro n(a,b) with set values for a and b for each specific y (So for y=19 the macro n(a,b) should run two times: once where a=d and b=7, and a second time where a=o and b=8). Then the macro nn runs a chunk of code that is the same for all y.

The macro n(a,b) is supposed to import the files which differ in name (some are 2019_X, some are 19_X); this difference is connected to a being equal to "d" or "o". If a=d files to import take the name 2019_X, and if a=o files to import take the name 19_X. Then it should append the two files d and o.

 

 

I hope it is clear what I want to do, but if not please ask me for more detail. Thanks in advance for your help.

 

13 REPLIES 13
PaigeMiller
Diamond | Level 26

The problem is not caused by macro within a macro (which is not recommended). The problem is that you have written incorrect macro code, as stated clearly by the WARNING message. Please go back to your original title and give a better title, such as "Macro variable not resolved". 

 

WARNING: Apparent symbolic reference Y_ not resolved.

 

You are trying to use macro variable &Y_ which does not exist. Perhaps you meant this:

 

out=b&y._&j

 

Note the . in the above code, this ends the macro variable name, the macro variable name is &y and without the dot (as you tried) the macro variable name is &y_ which does not exist.

 

 

Better, you should arrange your code like this and then avoid nesting of macros.

 

%macro nn(y);
    ... the rest of macro %nn goes here ...
%mend nn;

%macro n(a,b);
    ... the rest of macro %n goes here ...
%mend n;
   

 

 

--
Paige Miller
Satori
Quartz | Level 8
thanks. I followed your advices.

I got the following error so it seems there is still an issue with the macro variable name:

ERROR: Physical file does not exist, /data/bvd/xlsx//20&y._&j.
NOTE: The SAS System stopped processing this step because of errors.
Tom
Super User Tom
Super User

@Satori wrote:
thanks. I followed your advices.

I got the following error so it seems there is still an issue with the macro variable name:

ERROR: Physical file does not exist, /data/bvd/xlsx//20&y._&j.
NOTE: The SAS System stopped processing this step because of errors.

If you want the macro processor to treat &y. and &j. as references to macro processors you should not HIDE them from its view. The macro processor ignores contents of string constants bounded by single quotes.

proc import datafile='/data/bvd/xlsx/20&y_&j.xlsx'

Use double quotes. 

proc import datafile="/data/bvd/xlsx/20&y_&j.xlsx"
Satori
Quartz | Level 8

This is the updated code:

 

libname bvd '/data/bvd';
option ls=180 ps=500;

%macro nn(y); %do;
%if &y=19 %then %do;
%n(d,7);
%n(o,8);
%end;

%if &y=20 %then %do;
%n(d,11);
%n(o,7);
%end;

%if &y=21 %then %do;
%n(o,14);
%end;

%if &y=22 %then %do;
%n(o,26);
%end;

data temp; set b&y.; retain _CNAME; if CNAME ne "" then _CNAME=CNAME; if CNAME eq "" then CNAME=_CNAME; drop _CNAME; proc sort; by CNAME;

data bvd.b&y.; set temp; by CNAME; retain _BVDID _XASSTS _XEMPL _SIC1 _SIC2 _XREV;
	if not last.CNAME then do; if BVDID ne "" then _BVDID=BVDID; if XASSTS ne . then _XASSTS=XASSTS; if SIC1 ne . then _SIC1=SIC1;
	if SIC2 ne . then _SIC2=SIC2; if XEMPL ne . then _XEMPL=XEMPL; if XREV ne . then _XREV=XREV; end; 
	if not first.CNAME then do; if BVDID eq "" then BVDID= _BVDID; if XASSTS eq . then XASSTS=_XASSTS; if SIC1 eq . then SIC1=_SIC1;
	if SIC2 eq . then SIC2=_SIC2; if XEMPL eq . then XEMPL=_XEMPL; if XREV eq . then XREV=_XREV; end; drop _:;

%end;
%mend;


%macro n(a,b); %do j=1 %to &b;
%if &a=d %then %do;
proc import datafile="/data/bvd/xlsx/20&y._&j..xlsx" out=b&y._&j dbms=xlsx replace;
data &a&y.; length BVDID $20. CNAME $50.; set b&y._1-b&y._&j; Source="D";
%end;

%if &a=o %then %do;
proc import datafile="/data/bvd/xlsx/&y._&j..xlsx" out=b&y._&j dbms=xlsx replace;
data &a&y.; length BVDID $20. CNAME $50.; set b&y._1-b&y._&j; Source="O";
%end;

data b&y.; set d&y. o&y.; XASSTS=max(ASSTS,SHFU); XREV=max(OPRE,SALE); XEMPL=EMPL; drop ASSTS SHFU OPRE SALE;

%end;
%mend;


%nn(19);
%nn(20);
%nn(21);
%nn(22);

But I'm still getting an error. For some reason it is not creating the file o_

 

NOTE: There were 184507 observations read from the data set WORK.B19_1.
NOTE: The data set WORK.D19 has 184507 observations and 17 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.05 seconds
      

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

NOTE: The SAS System stopped processing this step because of errors.
NOTE: Due to ERROR(s) above, SAS set option OBS=0, enabling syntax check mode. This prevents execution of subsequent data modification statements.

 

PaigeMiller
Diamond | Level 26
ERROR: File WORK.O19.DATA does not exist.

 

This should be self-explanatory, your macro is looking for a data set that doesn't exist. What data set are you expecting here?

 

Please, @Satori show us the full log for the step (in this case the DATA step) that has errors, including the code for that step as it appears in the log. Error messages detached from the code that caused the error message are useless. Please do this EVERY time.

--
Paige Miller
Satori
Quartz | Level 8

My expectation is for it to create two sets: d_ and o_ then append the two, but the set o_ is not being created.

 

My full log:

 

1          libname bvd '/data/bvd';
NOTE: Libref BVD was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /data/bvd
2          option ls=180 ps=500;
3          
4          %macro nn(y); %do;
5          %if &y=19 %then %do;
6          %n(d,7);
7          %n(o,8);
8          %end;
9          
10         %if &y=20 %then %do;
11         %n(d,11);
12         %n(o,7);
13         %end;
14         
15         %if &y=21 %then %do;
16         %n(o,14);
17         %end;
18         
19         %if &y=22 %then %do;
20         %n(o,26);
21         %end;
22         
23         data temp; set b&y.; retain _CNAME; if CNAME ne "" then _CNAME=CNAME; if CNAME eq "" then CNAME=_CNAME; drop _CNAME; proc sort; by CNAME;
24         
25         data bvd.b&y.; set temp; by CNAME; retain _BVDID _XASSTS _XEMPL _SIC1 _SIC2 _XREV;
26         	if not last.CNAME then do; if BVDID ne "" then _BVDID=BVDID; if XASSTS ne . then _XASSTS=XASSTS; if SIC1 ne . then _SIC1=SIC1;
27         	if SIC2 ne . then _SIC2=SIC2; if XEMPL ne . then _XEMPL=XEMPL; if XREV ne . then _XREV=XREV; end;
28         	if not first.CNAME then do; if BVDID eq "" then BVDID= _BVDID; if XASSTS eq . then XASSTS=_XASSTS; if SIC1 eq . then SIC1=_SIC1;
29         	if SIC2 eq . then SIC2=_SIC2; if XEMPL eq . then XEMPL=_XEMPL; if XREV eq . then XREV=_XREV; end; drop _:;
30         
31         %end;
32         %mend;
33         
34         
35         %macro n(a,b); %do j=1 %to &b;
36         %if &a=d %then %do;
37         proc import datafile="/data/bvd/xlsx/20&y._&j..xlsx" out=b&y._&j dbms=xlsx replace;
38         data &a&y.; length BVDID $20. CNAME $50.; set b&y._1-b&y._&j; Source="D";
39         %end;
40         
41         %if &a=o %then %do;
42         proc import datafile="/data/bvd/xlsx/&y._&j..xlsx" out=b&y._&j dbms=xlsx replace;
43         data &a&y.; length BVDID $20. CNAME $50.; set b&y._1-b&y._&j; Source="O";
44         %end;
45         
46         data b&y.; set d&y. o&y.; XASSTS=max(ASSTS,SHFU); XREV=max(OPRE,SALE); XEMPL=EMPL; drop ASSTS SHFU OPRE SALE;
47         
48         %end;
49         %mend;
50         
51         
52         %nn(19);
NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with options MSGLEVEL=I.
NOTE: The import data set has 184507 observations and 16 variables.
NOTE: WORK.B19_1 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           8.63 seconds
      cpu time            8.62 seconds
      


WARNING: Multiple lengths were specified for the variable CNAME by input data set(s). This can cause truncation of data.
NOTE: There were 184507 observations read from the data set WORK.B19_1.
NOTE: The data set WORK.D19 has 184507 observations and 17 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.05 seconds
      

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

NOTE: The SAS System stopped processing this step because of errors.
NOTE: Due to ERROR(s) above, SAS set option OBS=0, enabling syntax check mode. This prevents execution of subsequent data modification statements.
WARNING: The data set WORK.B19 may be incomplete.  When this step was stopped there were 0 observations and 16 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


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

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


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

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


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.

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


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

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


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.

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


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

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


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.

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


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

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


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.
ERROR: File WORK.B19_6.DATA does not exist.

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


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

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


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.
ERROR: File WORK.B19_6.DATA does not exist.
ERROR: File WORK.B19_7.DATA does not exist.

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


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

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


NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.



NOTE: The data set WORK.O19 has 0 observations and 17 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      


NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


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

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



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.

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



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.

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



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.

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



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.
ERROR: File WORK.B19_6.DATA does not exist.

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



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.
ERROR: File WORK.B19_6.DATA does not exist.
ERROR: File WORK.B19_7.DATA does not exist.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.O19 may be incomplete.  When this step was stopped there were 0 observations and 17 variables.
WARNING: Data set WORK.O19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
2                                                                                  The SAS System                                                       21:32 Monday, March 11, 2024

      cpu time            0.00 seconds
      



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: The SAS System stopped processing this step because of errors.


ERROR: File WORK.B19_2.DATA does not exist.
ERROR: File WORK.B19_3.DATA does not exist.
ERROR: File WORK.B19_4.DATA does not exist.
ERROR: File WORK.B19_5.DATA does not exist.
ERROR: File WORK.B19_6.DATA does not exist.
ERROR: File WORK.B19_7.DATA does not exist.
ERROR: File WORK.B19_8.DATA does not exist.

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



NOTE: The data set WORK.B19 has 0 observations and 16 variables.
WARNING: Data set WORK.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      


NOTE: The data set WORK.TEMP has 0 observations and 16 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      


NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

53         
54         /*
55         %nn(20);
56         %nn(21);
57         %nn(22);
58         */
59         
60         
61         
62         
63         
64         
65         

NOTE: The data set BVD.B19 has 0 observations and 16 variables.
WARNING: Data set BVD.B19 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

ERROR: Errors printed on pages 1,2.

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           8.87 seconds
      cpu time            8.79 seconds
      
PaigeMiller
Diamond | Level 26

@Satori please read carefully. This is what I said:

 

Please, @Satori show us the full log for the step (in this case the DATA step) that has errors

In  this case, since it is macro code, please turn on macro debugging by running this command and then run your program again and show us the requested part of the log.

 

options mprint;
--
Paige Miller
ballardw
Super User

Note that this part of  your log

WARNING: Multiple lengths were specified for the variable CNAME by input data set(s). This can cause truncation of data.
NOTE: There were 184507 observations read from the data set WORK.B19_1.
NOTE: The data set WORK.D19 has 184507 observations and 17 variables.
NOTE: DATA statement used (Total process time):

is one of the reasons why Proc Import is not really the tool for reading lots of files in an automated process.

Proc Import guesses the variable type and length separately for each file.

So when you combine them you can have different lengths (with the warning) or different types for the same named variable (which will be an error and the step will fail).

Guess what? You won't even know if any data was lost unless you compare carefully the two (or more) data sets involved.

Kurt_Bremser
Super User

Depending on the value of parameter a, your macro will either run the branch which creates the Dxx or the branch which creates the Oxx dataset, but never both. But then, it tries to concatenate both.

yabwon
Onyx | Level 15

Macro variables calls do NOT resolve if they are inside single quotes text strings.

This:

'&y.'

will NOT resolve, you have to make it:

"&y."

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

As @PaigeMiller wrote, dots (".") in multiple places are missing.

Here is SAS documentation as a support:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0700fspmubii5n1vecutttwz93n.htm#n0f...

 

Bart

 

P.S. I also agree with the suggestion about restructuring your code not to have one macro definition inside another macro.

There are very rare special cases when having macro definition in side other are needed but in 99.99% cases such practice is waste of resources.

It's a resources wasting because whenever "external" macro is executed the "internal" one is compiled every time.

If you run "external" one 1000 times, the "internal" one will be compiled 1000 times, when it's enough to generate it only 1 time.

 

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Kurt_Bremser
Super User

Defining a macro within a macro is always a BAD IDEA.

Why?

All macros exist in the global scope anyway, so trying to make it look otherwise is just confusing, and makes code less readable.

 

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
  • 13 replies
  • 876 views
  • 8 likes
  • 6 in conversation