Calcite | Level 5

## Linear Generalized model

Hello! This is my thesis project. I want to know the influence of THI (temperature and humidity index) on the EIPH (excercise induced pulmonary haemorrhage) in horses. We did an average of THI for each month.  I want to do the same relation for each part (in the program) but separating it by year and by month. This analysis part 1: I did the relation with THI and Positive/negatives to bleeding and part 2: I divided the grades of eiph into slightly/serious bleeding. This may help you out to understand it. I tried many ways but it always came with an error in the model. I just took the class, so I only know the basics. If you can help me out here, I'll appreciate it!

``````FILENAME REFFILE '/folders/myfolders/sasuser.v94/DatosFinales_ITH.xlsx';

PROC IMPORT DATAFILE=REFFILE DBMS=XLSX OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT;
proc print;
RUN;

libname eiph '/folders/myfolders/sasuser.v94/';

data eiph.import;
set import;
run;

proc sgplot data=eiph.import pctlevel=group;
vbar thi /stat=percent group=eiph grouporder=data;
title "Proporciones por grado de EIPH según el ITH";

proc sgplot data=eiph.import;
vline mes/ response=thi stat=mean markers group=year;
title 'VALORES DE ITH POR MES Y POR AÑO';

Proc freq data=eiph.import;
Tables thi*eiph/nocol nopercent chisq;
Run;

data eiphpos;
set IMPORT;

if eiph=0 then
eiphpos=0;

if eiph>0 then
eiphpos=1;

proc glimmix data=eiphpos;
class thi;
model eiphpos(descending)=THI / dist=binary link=logit solution;

proc sgplot data=eiphpos pctlevel=group;
vbar thi /stat=percent group=eiphpos grouporder=data;

Proc freq data=eiphpos;
Tables thi*eiphpos/nocol nopercent chisq;
Run;

by thi eiphp;

series x=THI y=eiphp;
scatter x=THI y=eiphpos / jitter;
run;

set IMPORT;

if eiph>=4 then

if eiph<4 then

if eiph=0 then

class thi;
lsmeans thi / pdiff lines ilink;

Run;

by thi eiphg;

series x=THI y=eiphg;
run;``````

7 REPLIES 7
Super User

## Re: Linear Generalized model

Welcome to the SAS forums.

I think we'll need some more information here. For example, you're saying:

I tried many ways but it always came with an error in the model.

But we don't know what errors are occurring and don't have your data so we can't run the code either. If you could include the error and log that will likely help. Additionally, you can also comment your code, this tells us what you think each section is doing, and then we can try and verify if the logic is correct for your intentions. Code can be correct syntactically but not what you intended, ie logic errors.

It would probably help if you could include some data so we can run the code as well. If you can't for confidentiality reasons, you can try to see if you can find a data set in the SASHELP library or SAS documentation that's similar enough and modify your code to work with that data set. SASHELP. HEART may be suitable for example.

PS. If you can format your code and post in the correct sub forum that helps. I've formatted your code (the second last icon in SAS Studio does this automatically) and moved your post to the stats forum so hopefully someone can help.

Spoiler

Hello! This is my thesis project. I want to know the influence of THI (temperature and humidity index) on the EIPH (excercise induced pulmonary haemorrhage) in horses. We did an average of THI for each month.  I want to do the same relation for each part (in the program) but separating it by year and by month. This analysis part 1: I did the relation with THI and Positive/negatives to bleeding and part 2: I divided the grades of eiph into slightly/serious bleeding. This may help you out to understand it. I tried many ways but it always came with an error in the model. I just took the class, so I only know the basics. If you can help me out here, I'll appreciate it!

``````FILENAME REFFILE '/folders/myfolders/sasuser.v94/DatosFinales_ITH.xlsx';

PROC IMPORT DATAFILE=REFFILE DBMS=XLSX OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT;
proc print;
RUN;

libname eiph '/folders/myfolders/sasuser.v94/';

data eiph.import;
set import;
run;

proc sgplot data=eiph.import pctlevel=group;
vbar thi /stat=percent group=eiph grouporder=data;
title "Proporciones por grado de EIPH según el ITH";

proc sgplot data=eiph.import;
vline mes/ response=thi stat=mean markers group=year;
title 'VALORES DE ITH POR MES Y POR AÑO';

Proc freq data=eiph.import;
Tables thi*eiph/nocol nopercent chisq;
Run;

data eiphpos;
set IMPORT;

if eiph=0 then
eiphpos=0;

if eiph>0 then
eiphpos=1;

proc glimmix data=eiphpos;
class thi;
model eiphpos(descending)=THI / dist=binary link=logit solution;

proc sgplot data=eiphpos pctlevel=group;
vbar thi /stat=percent group=eiphpos grouporder=data;

Proc freq data=eiphpos;
Tables thi*eiphpos/nocol nopercent chisq;
Run;

by thi eiphp;

series x=THI y=eiphp;
scatter x=THI y=eiphpos / jitter;
run;

set IMPORT;

if eiph>=4 then

if eiph<4 then

if eiph=0 then

class thi;
lsmeans thi / pdiff lines ilink;

Run;

by thi eiphg;

series x=THI y=eiphg;
run;``````

Calcite | Level 5

## Re: Linear Generalized model

That's the data.

That code runs perfectly. I just want to know how can I do the same analysis but dividing it by years and by months to see when it can be significant the relationship THI*EIPH.

Super User

## Re: Linear Generalized model

Do you want the model run for each year/month? If so, add a BY statement (you may need to sort your data). A BY statement takes multiple variables and basically performs the same action across that group of variables. However, if you're looking to determine the effects of year/month you may want to add them into he model as variables, though if you have time series data you should verify stationarity and such first.

For example, if you wanted to run a separate regression model by sex this would do that:

``````proc sort data=sashelp.class out=class;
by sex;
run;

proc reg data=class;
by sex;
model weight = height age;
run;``````
Calcite | Level 5

## Re: Linear Generalized model

Hi again! I tried the by statement and the numbers remained the same. How I put them as a third variable in the model? Because it says that can't be done.

Super User

## Re: Linear Generalized model

Hi again! I tried the by statement and the numbers remained the same. How I put them as a third variable in the model? Because it says that can't be done.

I don't know what either of that means. Please explain in detail.

Super User

## Re: Linear Generalized model

Hi again! I tried the by statement and the numbers remained the same. How I put them as a third variable in the model? Because it says that can't be done.

Show the code you attempted.

It is often self defeating to attempt to put BY variable on a model as each by group will have only one set of values for the variable(s).

if you do some thing like:

Proc glm data=mydata;

by year month;

model thisvar = thatvar year month;

then the data processes so that each of the models (one for each year/month combination)  in effect look like:

model thisvar = thatvar 2018 1  ; (for year=2018 and month = 1). and tries to create parameters to assign to year/month.

the syntax

Proc glm data=mydata;

by year month;

model thisvar = thatvar ;

creates one model for each combination of year and month without attempting to create parameters for the year and month varaibles.

Any of your output data sets would have the values of year and month as well so you can see/ compare/ whatever based on those.

SAS Super FREQ

## Re: Linear Generalized model

Hi again! I tried the by statement and the numbers remained the same. How I put them as a third variable in the model? Because it says that can't be done.

Be sure that you understand the difference between BY variables and CLASS variables in SAS. If you want to be able to compare the effects of different months and days, they need to be class variables and part of the model. If you just want to subset the data by month and day, then use the BY statement.

Discussion stats
• 7 replies
• 1688 views
• 2 likes
• 4 in conversation