turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Please Help new to sas and struggling with project

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-09-2017 07:51 AM

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.**

- Test the mean difference in percent weight change by BMI category in three models:
- Unadjusted (Model 1)
- Adjusted for age (Model 2)
- Adjusted for age and menopause status (Model 3)

- Test the mean difference in percent weight change by number of children (categorical variable) in three models:
- Unadjusted
- Adjusted for age
- Adjusted for age, BMI and menopause status
- 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.**

- 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. - 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:
- BMI
- BMI categories using the Underweight / normal weight category as the referent

- Percent weight change

- Menopausal status
- Number of kids (using “No children” as the referent category)
- 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"));

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to eee100

12-11-2017 01:26 PM

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.