Hi! I'm trying to write a macro that will pick a base mean and compare all the other means in my dataset to that mean (by doing a t-test). I also want to compare all the means to the international mean. I want my ouput to be a table that has the country ID (IDCNTRY), the mean (mnpv), the standard error (mnpv_se), the t value, and the label for 'H' or 'L' to indicate if the means are significantly higher or lower. Here is what I have but I keep getting errors: %MACRO T(YEAR=, FILE=, base=, scale_name=, TABLE=); %put TABLE: &TABLE.; ODS SELECT NONE; proc sql; select mnpv, mnpv_se into :mean_base, :mean_se_base from OUTDIR.&FILE._&TABLE. where IDCNTRY="&base"; quit; proc sql; CREATE TABLE &scale_name. AS SELECT IDCNTRY, mnpv AS &scale_name._Mean, mnpv_se AS &scale_name._SE, mnpv_se * mnpv_se AS &scale_name._SE_Square, /* international average */ (mnpv - 496) / mnpv_se AS &scale_name._t_500, ((mnpv - 496) / mnpv_se ) / 1.96 AS &scale_name._t_cv_500, CASE WHEN calculated &scale_name._t_cv_500 >= 1 THEN ' H' WHEN -1 < calculated &scale_name._t_cv_500 < 1 THEN ' ' WHEN calculated &scale_name._t_cv_500 <= -1 THEN ' L' END AS &scale_name._sig_500, /* comparing to base group */ (mnpv - &mean_base.) / sqrt(mnpv_se**2 + &mean_se_base.**2) AS &scale_name._t_base, ((mnpv - &mean_base.) / sqrt(mnpv_se**2 + &mean_se_base.**2)) / 1.96 AS &scale_name._t_cv_base, CASE WHEN calculated &scale_name._t_cv_base >= 1 THEN ' H' WHEN -1 < calculated &scale_name._t_cv_base < 1 THEN ' ' WHEN calculated &scale_name._t_cv_base <= -1 THEN ' L' END AS &scale_name._sig_base FROM OUTDIR.&FILE._&TABLE. ORDER BY IDCNTRY; QUIT; proc sql; CREATE TABLE &scale_name._2 AS SELECT * FROM &scale_name. ORDER BY IDCNTRY, &scale_name._Mean DESC; QUIT; ods select all; PROC PRINT DATA=&scale_name.; TITLE "&TABLE.: &scale_name."; FORMAT _NUMERIC_ 20.5; RUN; %MEND T; /*----------------------------------------------------------*/ /* Table 1. */ %T(YEAR=2018, FILE=D2018, base=USA scale_name= CIL TABLE= TABLE1); What am I missing??
... View more