BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
u49589061
Fluorite | Level 6
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."

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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

--
Paige Miller

View solution in original post

3 REPLIES 3
japelin
Rhodochrosite | Level 12

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;

 

PaigeMiller
Diamond | Level 26

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

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1352 views
  • 3 likes
  • 4 in conversation