BookmarkSubscribeRSS Feed
eee100
Calcite | Level 5

Guys, I am seriously struggling programming, I am new to any computer programming and my professor has not been much help at all when it comes to teaching the course. I have attached the combined dataset and here are the questions i need help with. I cannot figure out what is wrong with my code because I do have to use the code she is asking for. 

 

Q9. Use a single macro with two parameters to assess the correlation between mean fasting glucose and age, body composition, blood pressure and lipid concentrations
a. Obtain unadjusted correlations between mean fasting plasma glucose and age, weight, weight at age of 20, percent weight change, waist to hip ratio, BMI, HDL cholesterol, total cholesterol, the ratio of total to HDL cholesterol (as a continuous variable), systolic blood pressure and diastolic blood pressure.
b. Obtain age-adjusted correlation coefficients for the above-mentioned correlation tests (except for the correlation between mean fasting plasma glucose and age)

 

Here is my code that is not correct:

%macro mycorr(&a=, &b=);
proc corr data=PJ123 spearman;
var meanFG;
with &a;
only &b;
run;
%mend mycorr;

%mycorr(a=Age weight20 WTPCT WHR BMI HDL CHOL TCHDL SBP DBP);
%mycorr partial (a=weight20 WTPCT WHR BMI HDL CHOL TCHDL SBP DBP, b=age);

 

 

 

Q10. 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 incorrect 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);

 

Use linear regression models (PROC REG) to assess correlates of mean fasting plasma glucose concentrations.

  1. Note that dummy variables should be created for categorical variables with more than two levels. Create dummy variables for BMIcat, NKIDS, and TCHDL_Q using arrays.  Use the appropriate procedure to check the dummy variables created against the original categorical variables.
  2. Using a macro code with one parameter, construct separate linear regression models with mean fasting plasma glucose as the dependent (outcome) variables and each of the following (separate models for each) as the independent variable:
    1. BMI
    2. BMI categories using the Underweight / normal weight category as the referent
  • Percent weight change
  1. Menopausal status
  2. Number of kids (using “No children” as the referent category)
  3. Quartiles of the ratio of total to HDL cholesterol (using the 1st quartile as the referent category).

Here is my code: ( i have already done part A correctly)

 


%macro regress(predictors);
proc reg data=PJ123;
model meanFG= &predictors;
run;
%mend regress;

%regress(BMI);
%regress(BMIcat (ref="dBMIcat1");
%regress(WTPCT
%regress(MNP);
%regress(NKIDS)(ref="dNKIDS1"));
%regress(TCHDL_q (ref="dTCHDL1"));

 

 

 

1 REPLY 1
ballardw
Super User

@eee100 wrote:

Guys, I am seriously struggling programming, I am new to any computer programming and my professor has not been much help at all when it comes to teaching the course. I have attached the combined dataset and here are the questions i need help with. I cannot figure out what is wrong with my code because I do have to use the code she is asking for. 

 

Q9. Use a single macro with two parameters to assess the correlation between mean fasting glucose and age, body composition, blood pressure and lipid concentrations
a. Obtain unadjusted correlations between mean fasting plasma glucose and age, weight, weight at age of 20, percent weight change, waist to hip ratio, BMI, HDL cholesterol, total cholesterol, the ratio of total to HDL cholesterol (as a continuous variable), systolic blood pressure and diastolic blood pressure.
b. Obtain age-adjusted correlation coefficients for the above-mentioned correlation tests (except for the correlation between mean fasting plasma glucose and age)

 

 

 


If those are examples of what the instructor is requiring, "use a single macro" for example, I suspect that you may have skipped a prerequisite. Macros are not beginning SAS code. Your SAS install should have included some online help. There are examples of many of the basic features of the procedures in the "Learning to Use SAS" section of the Contents tab as well as full syntax for the procedures either navigating the Contents or putting a search term like CORR in the Index or Search tabs. The procedure details will have worked examples with data sets and even explanations of what specific code does in many cases.

 

 

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