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

Hello members,

Can you please help me find out what's wrong with the red part? Thanks!!!!!

 


%macro cov (cutt,cutc);
%do i=1 %to 2;
data covA&i.;
infile "&pathr.WS1_A.rep&i..sc" FIRSTOBS=3 OBS=43 missover pad;
input
rawA&i. 5-6
thetaA&i. 10-15;
run;
data covB&i.;
infile "&pathr.WS2_B.rep&i..sc" FIRSTOBS=3 OBS=43 missover pad;
input
rawB&i. 5-6
thetaB&i. 10-15;
run;

data conAB&i.;
merge covA&i. covB&i.;
diffA&i.=abs(thetaA&i.-&cutt.);
diffB&i.=abs(thetaB&i.-&cutt.);
run;

proc print data=conAB&i.;run;

proc sql noprint;
select min(abs(thetaA&i.-&cutt.)) into :minthetaA&i. from conAB&i. where thetaA&i.>=0;
select min(abs(thetaB&i.-&cutt.)) into :minthetaB&i. from conAB&i. where thetaB&i.>=0;
quit;
%put minimum thetaA diff is &&minthetaA&i.;
%put minimum thetaB diff is &&minthetaB&i.;

proc sql noprint;
select rawA&i. into :rawA&i. from conAB&i. where diffA&i.= &&minthetaA&i.;
select rawB&i. into :rawB&i. from conAB&i. where diffB&i.= &&minthetaB&i.;
quit;
%put raw cutA is &&rawA&i.;
%put raw cutB is &&rawB&i.;

data cut&cutc.&i.;
cutrawA=&&rawA&i.;
cutrawB=&&rawB&i. ;
run;

%if &i=1 %then %do; data cov&cutc.;set cut&cutc.&i.;run;%end;
%else %do; data cov&cutc.;set cov&cutc. cut&cutc.&i.;run; %end;

%end;
%mend;
%cov (cutt=0, cutc=zero);
%cov (cutt=0.5,cutc=low);

 

 

------------------------- log-----


WARNING: Apparent symbolic reference RAWA1 not resolved.
raw cutA is &rawA1
WARNING: Apparent symbolic reference RAWB1 not resolved.
raw cutB is &rawB1
NOTE: Line generated by the macro variable "I".
1 &rawA1
-
22
WARNING: Apparent symbolic reference RAWA1 not resolved.
NOTE: Line generated by the macro variable "I".
1 &rawB1
-
22
WARNING: Apparent symbolic reference RAWB1 not resolved.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, INPUT, PUT.

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Other than the fact that you seem to be trying to put data into macro variables instead of just keeping the data in real variables in datasets?

 

If the SQL query does not create the macro variable if no observations are selected.  Make sure to define them in case of no matches.

proc sql noprint;
%let rawA&i = ;
%let rawB&i = ;
select rawA&i. into :rawA&i. from conAB&i. where diffA&i.= &&minthetaA&i.;
select rawB&i. into :rawB&i. from conAB&i. where diffB&i.= &&minthetaB&i.;
quit;

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Other than the fact that you seem to be trying to put data into macro variables instead of just keeping the data in real variables in datasets?

 

If the SQL query does not create the macro variable if no observations are selected.  Make sure to define them in case of no matches.

proc sql noprint;
%let rawA&i = ;
%let rawB&i = ;
select rawA&i. into :rawA&i. from conAB&i. where diffA&i.= &&minthetaA&i.;
select rawB&i. into :rawB&i. from conAB&i. where diffB&i.= &&minthetaB&i.;
quit;

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 499 views
  • 2 likes
  • 2 in conversation