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.
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.
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"));
@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.
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!
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.