BookmarkSubscribeRSS Feed
charbel
Fluorite | Level 6

Hi, sorry but I think you're responding to an earlier version of the macro which I modified. It shouldn't include this macro:

%effect_size( data=che_lim, idvar=unique_id, groupvar=tx_area, respvars=hc_cat BSI TRGI CESD, cl=0.95) 

 

I don't have access to the macro at this time but will come back to this as soon as I can tomorrow morning.

 

I'm very grateful for everyone who responded so far.

charbel
Fluorite | Level 6

thanks again everyone about input yesterday. As you pointed out I'm very new to using SAS macros.

 

The current macro is:

%macro effect_size( data,idvar,design,groupvar, timevar, timeval1, timeval2,respvars,cl=0.95);                                                                      
 %if &groupvar^= tx_area1 and &timevar^= rounds %then %do;                                                                                                          
 proc sql noprint;                                                                                                                                                  
select distinct(&groupvar) into :grp1-:grp2 from  &data;                                                                                                            
quit;                                                                                                                                                               
                                                                                                                                                                    
** to calculate effect size of 2-group pre-post design***;                                                                                                          
** make two separate data set for group 1 and group 2****;                                                                                                          
                                                                                                                                                                    
data data_&grp1(keep=&idvar &timevar &respvars) data_&grp2(keep=&idvar &timevar &respvars);                                                                         
 set &data;                                                                                                                                                         
if &groupvar=&grp1 then output data_&grp1;                                                                                                                          
if &groupvar=&grp2 then output data_&grp2;                                                                                                                          
run;                                                                                                                                                                
                                                                                                                                                                    
* Noow calculate effect size for both groups*********************;                                                                                                  
 * using either design 1(independent) or design 2 paired desig)***;                                                                                                 
                                                                                                                                                                    
%eff_size_paired(data=data_&grp1,idvar=&idvar,design=&design, timevar=&timevar,timeval1=&timeval1,                                                                  
timeval2=&timeval2, respvars=&respvars,cl=&cl,outdata=effectsize_table&grp1)                                                                                        
%eff_size_paired(data=data_&grp2,design=&design,idvar=&idvar, timevar=&timevar,timeval1=&timeval1,                                                                  
timeval2=&timeval2, respvars=&respvars,cl=&cl,outdata=effectsize_table&grp2)                                                                                        
                                                                                                                                                                    
* combine two tables to get effect size***; * IGPP design is square root of sum of variance ****;                                                                   
                                                                                                                                                                    
proc sql;                                                                                                                                                           
create table effectsize_table_IGPP as                                                                                                                               
select trim(a.Response) ||"&grp1"||"-"||trim(a.Response)||"&grp2" as                                                                                                
Response,                                                                                                                                                           
a.n as n_&grp1,                                                                                                                                                     
a.mean1 as M1_&grp1 format 8.2, a.sd1 as SD1_&grp1 format=8.2,                                                                                                      
a.mean2 as M2_&grp1 format=8.2, a.sd2 as SD2_&grp1 format=8.2,                                                                                                      
b.n as n_&grp2,                                                                                                                                                     
b.mean1 as M1_&grp2 format=8.2, b.sd1 as SD1_&grp2 format=8.2,                                                                                                      
b.mean2 as M2_&grp2 format=8.2, b.sd2 as SD2_&grp2 format=8.2,                                                                                                      
a.effect_size - b.effect_size as eff_size,                                                                                                                          
calculated eff_size-PROBIT(.50+&cl/2)*(sqrt(a.se_d**2+b.se_d**2)) as CI_LOW,                                                                                        
calculated eff_size+PROBIT(.50+&cl/2)* (sqrt(a.se_d**2+b.se_d**2)) as CI_UP                                                                                         
from work.effectsize_table&grp1 as a, work.effectsize_table&grp2 as b                                                                                               
where a.Response=b.response;                                                                                                                                        
 quit;                                                                                                                                                              
                                                                                                                                                                    
%goto printresult;                                                                                                                                                  
%end;                                                                                                                                                               
                                                                                                                                                                    
** calculate macro variable for confidence level***;                                                                                                                
                                                                                                                                                                    
%printresult:                                                                                                                                                       
                                                                                                                                                                    
** Print results***;                                                                                                                                                
** Print results***;                                                                                                                                                
                                                                                                                                                                    
ods html path='c:\temp' (url=none) file='survey_data_eff_size.html';                                                                                                
                                                                                                                                                                    
                                                                                                                                                                    
                                                                                                                                                                    
%if &groupvar^= tx_area1 and &timevar^= rounds %then %do;                                                                                                           
title "Table 1: Effect Size (Cohen'd) and its Confidence Interval for Independent Group Pretest Posttest Design(IGPP)";                                             
proc sql nonumber;                                                                                                                                                  
select * from work.effectsize_table_IGPP;                                                                                                                           
quit;                                                                                                                                                               
title;                                                                                                                                                              
%end;                                                                                                                                                               
ods html close;                                                                                                                                                     
%mend effect_size;                                                                                                                                                  
                                                                                                                                                                    
                                                                                                                                                                    
options symbolgen;                                                                                                                                                  
                                                                                                                                                                    
                                                                                                                                                                    
** Ind. Group Pre-Post design:  (sd calculated from change scores) *;                                                                                               
** Ind. Group Pre-Post design:  (sd calculated from change scores) *;                                                                                               
                                                                                                                                                                    
%effect_size(data=che_lim, idvar=unique_id, design=1, groupvar=tx_area1, timevar=rounds, timeval1=1, timeval2=2, respvars=hc_cat , cl=0.95) 

 

I changed the ODS statement to: 

ods html path='c:\temp' (url=none) file='survey_data_eff_size.html';     as suggested on SAS support

 

When I run the macro I get:

NOTE: Writing HTML Body file: survey_data_eff_size.html
SYMBOLGEN:  Macro variable GROUPVAR resolves to tx_area1
SYMBOLGEN:  Macro variable TIMEVAR resolves to rounds

 

when I use a local drive such as:

ods html file='I:\RTs_and_Projects\Integrated_Surveillance_Systems_RT\Interamerican_Development_Bank\PUBLICATIONS\DID in health expenditure\survey_data_eff_size.html';

 

I also get:

NOTE: Writing HTML Body file:
      I:\RTs_and_Projects\Integrated_Surveillance_Systems_RT\Interamerican_Development_Bank\PUBLICATIO
      NS\DID in health expenditure\survey_data_eff_size.html
SYMBOLGEN:  Macro variable GROUPVAR resolves to tx_area1
SYMBOLGEN:  Macro variable TIMEVAR resolves to rounds

 

I can see that you're all pointing to what groupvar and timevar are resolving to as the issue but I honestly can't understand or guess how to fix that. 

Kurt_Bremser
Super User

You supply groupvar as tx_area1, but the macro tests for the contents of groupvar to not be tx_area1. This condition is obviously false, so nothing of the code inside the %do-%end blocks is created by the macro, and nothing happens. Only the ODS statements, which are outside the conditional block, are created by the macro and executed.

 

Similar happens for timevar.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 2653 views
  • 1 like
  • 4 in conversation