Please Help new to sas and struggling with project

Reply
Occasional Contributor
Posts: 7

Please Help new to sas and struggling with project

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"));

 

 

 

Super User
Posts: 12,148

Re: Please Help new to sas and struggling with project


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.

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 136 views
  • 0 likes
  • 2 in conversation