BookmarkSubscribeRSS Feed
eee100
Calcite | Level 5

Help my macro code is not working 

 

Here is the question I am asked: 

. Assess mean differences in percent weight change by categories of BMI and by the number of children using regression models.  The dependent (outcome) variable each time should be percent weight change.  The main independent variable would be either BMI categories or number of children.  Use one macro with two parameters to complete this question.

  1. Test the mean difference in percent weight change by BMI category in three models:
    1. Unadjusted (Model 1)
    2. Adjusted for age (Model 2)
    3. Adjusted for age and menopause status (Model 3)
  2. Test the mean difference in percent weight change by number of children (categorical variable) in three models:
  3. Unadjusted
  4. Adjusted for age
  5. Adjusted for age, BMI and menopause status
  6. From the above analysis, complete Table 3, making sure you report adjusted means when more than a single variable is included in the model (Type 3 SS). Also make sure you report p-values adjusted for multiple comparisons for categorical variables with more than two levels (use the Bonferroni correction for multiple comparisons).

Here is my code:

 

%macro myglm(class=, indep=);
proc glm data=&PJ123;
class &class;
model WTPCT = &class &indep;
means &class;
lsmeans &class / adjust=bon stderr pdiff;
run;
%mend myglm;

%myglm (class=BMICAT);
%myglm (class=BMICAT, indep=Age);
%myglm (class=BMICAT MNP, indep=Age);
%myglm (class=NKIDS);
%myglm (class=NKIDS, indep=Age);
%myglm (class=NKIDS BMI MNP, indep=Age);

 

Here is my error message:

 


326
327 %macro myglm(class=, indep=);
328 proc glm data=&PJ123;
329 class &class;
330 model WTPCT = &class &indep;
331 means &class;
332 lsmeans &class / adjust=bon stderr pdiff;
333 run;
334 %mend myglm;
335
336 %myglm (class=BMICAT);
NOTE: Line generated by the invoked macro "MYGLM".
1 proc glm data=&PJ123; class &class; model WTPCT = &class &indep; means &class
-
22
200
1 ! ; lsmeans &class / adjust=bon stderr pdiff; run;
WARNING: Apparent symbolic reference PJ123 not resolved.
NOTE: Data file WORK.PJ123.DATA is in a format that is native to another host, or the file
encoding does not match the session encoding. Cross Environment Data Access will be used,
which might require additional CPU resources and might reduce performance.
NOTE: The previous statement has been deleted.
ERROR: Only CLASS variables allowed in this effect.
NOTE: The previous statement has been deleted.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR: A MODEL statement must be given.
337 %myglm (class=BMICAT, indep=Age);

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


NOTE: Line generated by the invoked macro "MYGLM".
1 proc glm data=&PJ123; class &class; model WTPCT = &class &indep; means &class;
-
22
200
1 ! lsmeans &class / adjust=bon stderr pdiff; run;
WARNING: Apparent symbolic reference PJ123 not resolved.
NOTE: Data file WORK.PJ123.DATA is in a format that is native to another host, or the file
encoding does not match the session encoding. Cross Environment Data Access will be used,
which might require additional CPU resources and might reduce performance.
NOTE: The previous statement has been deleted.
ERROR: Only CLASS variables allowed in this effect.
NOTE: The previous statement has been deleted.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR: A MODEL statement must be given.
338 %myglm (class=BMICAT MNP, indep=Age);

NOTE: PROCEDURE GLM used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


NOTE: Line generated by the invoked macro "MYGLM".
1 proc glm data=&PJ123; class &class; model WTPCT = &class &indep; means &class;
-
22
200
1 ! lsmeans &class / adjust=bon stderr pdiff; run;
WARNING: Apparent symbolic reference PJ123 not resolved.
NOTE: Data file WORK.PJ123.DATA is in a format that is native to another host, or the file
encoding does not match the session encoding. Cross Environment Data Access will be used,
which might require additional CPU resources and might reduce performance.
NOTE: The previous statement has been deleted.
ERROR: Only CLASS variables allowed in this effect.
NOTE: The previous statement has been deleted.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR: A MODEL statement must be given.
339 %myglm (class=NKIDS);

NOTE: PROCEDURE GLM used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


NOTE: Line generated by the invoked macro "MYGLM".
1 proc glm data=&PJ123; class &class; model WTPCT = &class &indep; means &class;
-
22
200
1 ! lsmeans &class / adjust=bon stderr pdiff; run;
WARNING: Apparent symbolic reference PJ123 not resolved.
NOTE: Data file WORK.PJ123.DATA is in a format that is native to another host, or the file
encoding does not match the session encoding. Cross Environment Data Access will be used,
which might require additional CPU resources and might reduce performance.
NOTE: The previous statement has been deleted.
ERROR: Only CLASS variables allowed in this effect.
NOTE: The previous statement has been deleted.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR: A MODEL statement must be given.
340 %myglm (class=NKIDS, indep=Age);

NOTE: PROCEDURE GLM used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


NOTE: Line generated by the invoked macro "MYGLM".
1 proc glm data=&PJ123; class &class; model WTPCT = &class &indep; means &class;
-
22
200
1 ! lsmeans &class / adjust=bon stderr pdiff; run;
WARNING: Apparent symbolic reference PJ123 not resolved.
NOTE: Data file WORK.PJ123.DATA is in a format that is native to another host, or the file
encoding does not match the session encoding. Cross Environment Data Access will be used,
which might require additional CPU resources and might reduce performance.
NOTE: The previous statement has been deleted.
ERROR: Only CLASS variables allowed in this effect.
NOTE: The previous statement has been deleted.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR: A MODEL statement must be given.
341 %myglm (class=NKIDS BMI MNP, indep=Age);

NOTE: PROCEDURE GLM used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


NOTE: Line generated by the invoked macro "MYGLM".
1 proc glm data=&PJ123; class &class; model WTPCT = &class &indep; means &class;
-
22
200
1 ! lsmeans &class / adjust=bon stderr pdiff; run;
WARNING: Apparent symbolic reference PJ123 not resolved.
NOTE: Data file WORK.PJ123.DATA is in a format that is native to another host, or the file
encoding does not match the session encoding. Cross Environment Data Access will be used,
which might require additional CPU resources and might reduce performance.
NOTE: The previous statement has been deleted.
ERROR: Only CLASS variables allowed in this effect.
NOTE: The previous statement has been deleted.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR: A MODEL statement must be given.

1 REPLY 1

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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