Filename Refile '/home/u49589061/MPBH 421/Programs/condom.csv';
Proc import Datafile=Refile
DBMS=CSV
Out=work.condom;
Getnames=YES;
Run;
Proc contents data=work.condom;
Run;
Proc print data=work.condom;
Run;
Data condom1;
Set work.condom;
If gender="male" then gender=0;
Else gender=1;
If use="unprotected" then use=0;
Else use=1;
If safety gt 5 then delete;
If sexexp gt 10 then delete;
If previous="Condom us" then previous=0;
If previous="No condom" then previous=1;
Else previous=2;
If selfcon gt 9 then delete;
If perceive gt 6 then delete;
Previous1 = previous EQ 1;
Previous2 = previous EQ 2;
Run;
*****************************************************;
Proc logistic data=condom1;
class gender/param=ref;
Model use(ref=last)=perceive safety gender/expb cl rsq;
Output Out=condomres1 pred=pred;
Run;
PROC LOGISTIC DATA=condom;
Class gender/param=ref;
MODEL use (REF="0")= perceive safety gender previous1 previous2 selfcon sexexp /EXPB CL RSQ;
OUTPUT OUT=condomres2 PRED=pred ;
Test previous1=0, previous2=0, selfcon=0, sexexp=0;
Run;
- I need some major help for the following two parts:
First, I'm trying to make dummy variables for the variable: previous Previous1 = previous EQ 1;
Previous2 = previous EQ 2:
Second, I am currently running into problems with running the last two proc logistics statements. After I run the first proc logistic statement, it states that "All observations have the same response. No statistics are computed." And then when I run the second proc logistic statement, it states that the "variable previous1 was not found."
@u49589061 wrote:
Second, I am currently running into problems with running the last two proc logistics statements. After I run the first proc logistic statement, it states that "All observations have the same response. No statistics are computed."
Important debugging technique when you get this ERROR. Actually look at your data set with your own eyes and see what is happening. In this case, you will find that one of your variables has the same value for every observation. Then you have to fix this.
Also:
For Logistic Regression, do NOT create your own dummy variables. Just leave it as a character variable, and put the variable PREVIOUS in a CLASS statement. You gain nothing by converting it to numeric or creating dummy variables, but you do have to write extra code. Make your life easier, don't create your own dummy variables for Logistic Regression.
This may not be related to proc logistic, but I was curious about the following.
If previous="Condom us" then previous=0;
If previous="No condom" then previous=1;
Else previous=2;
I think there is an else missing in the second if, and all previous=0 assigned in the previous if statement will become previous=2.
This code might be better.
If previous="Condom us" then previous=0;
Else If previous="No condom" then previous=1;
Else previous=2;
For your second LOGISTIC: you use dataset condom, but you created previous1 in dataset condom1.
@u49589061 wrote:
Second, I am currently running into problems with running the last two proc logistics statements. After I run the first proc logistic statement, it states that "All observations have the same response. No statistics are computed."
Important debugging technique when you get this ERROR. Actually look at your data set with your own eyes and see what is happening. In this case, you will find that one of your variables has the same value for every observation. Then you have to fix this.
Also:
For Logistic Regression, do NOT create your own dummy variables. Just leave it as a character variable, and put the variable PREVIOUS in a CLASS statement. You gain nothing by converting it to numeric or creating dummy variables, but you do have to write extra code. Make your life easier, don't create your own dummy variables for Logistic Regression.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: