BookmarkSubscribeRSS Feed
sai99
Calcite | Level 5

Unable to call macro loadcpddata in macro loading:

 

 

data cpdlogic (sortedby=CPDCOBRS_VAR_NM CPDCOBRS_GRP_T);

set loaddata.cpdlogic;

if CPDCOBRS_CATG_T='CPD_logic' then do;

FieldCounterChar = left(put(_n_,6.));

 

FieldCounter = _n_;

output;

end;

run;

proc sql noprint;

select max(FieldCounter) into :TotalFieldCount

from cpdlogic ;

quit;

%put &TotalFieldCount;

 

%macro LoadCPDData (Group,Field_Num);

 

proc sql noprint;

select CPDCOBRS_VAR_NM into :FieldName

from cpdlogic

where CPDCOBRS_GRP_T=&Group

and FieldCounter=&Field_Num;

quit;

 

%put [&Field_Num];

%global &FieldName;

 

proc sql noprint;

select CPDCOBRS_RTRN_VLU_1 into :&FieldName

from cpdlogic

where CPDCOBRS_GRP_T=&Group;

quit;

%mend LoadCPDData;

 

 

%macro loading;

%if &TotalFieldCount > 1 %then %do;

%do i=1 %to &TotalFieldCount; 

%LoadCPDData(&cpd,&i);

%end;

%end;

%mend loading;

 

 

DATA:

 

CPDCOBRS_CATG_TCPDCOBRS_GRP_TCPDCOBRS_VAR_NMCPDCOBRS_RTRN_VLU_1
CPD_logic4DeanOrnish_paper_practvendY
CPD_logic6DeanOrnish_paper_practvendY
CPD_logic19DeanOrnish_paper_practvendY
CPD_logic47DeanOrnish_paper_practvendY
CPD_logic85DeanOrnish_paper_practvendY
CPD_logic95DeanOrnish_paper_practvendY
1 REPLY 1
Astounding
PROC Star

You're not very specific about what happens when you try to run this.  However, here's an issue that stands out.

 

For %LoadCPDData(&cpd,&i) to work, there must be an existing macro variable named CPD.  I don't see how your program creates that.

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
  • 1 reply
  • 539 views
  • 0 likes
  • 2 in conversation