BookmarkSubscribeRSS Feed
dharkey
Calcite | Level 5

Hello,

 

I am very new to SAS and I am completing an assignment for school, I am finally able to run my model but I am receiving the following: ERROR: All observations have the same response. No statistics are computed.

 

I have attached my SAS code below, "Analysis Ver 1" is the model I am trying to run and I receive the error and "creating working data ver 4" is the SAS code and cleaning of data.

 

Thank you for any help!!

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I never download attachments. You should (ALWAYS) include your code in your message by clicking on the "little running man" icon and then pasting it into the window that appears.

 

The error is more likely in your data, which has the same response for all observations. Please actually look at your data with your own eyes and see if this is the case.

 

If not, you can provide a portion of your data following these instructions. (Again, no attachments, please)

--
Paige Miller
ballardw
Super User

First a couple of generic comments.

Your code contains multiple calls such as this:

data workdata; set workdata;
Age=RIDAGEYR;

An important understanding is that when you use the same the same output data set name as the input set name SAS completely replaces the data set. So logic problems can mean that you destroy existing data and need to go back to early steps to recover the data.

Second is that you can place all of the recoding statements into a single call:

data newworkdata; set workdata;
Age=RIDAGEYR;
if RIAGENDR=1 then sex2=0;
if RIAGENDR=2 then sex2=1;

if sex2=0 then sex2_1=0;
if sex2=1 then sex2_1=1;
race5=RIDRETH1-1;
if race5=0 then do; race5_1=0; race5_2=0;  race5_3=0; race5_4=0; end;
if race5=1 then do; race5_1=1; race5_2=0;  race5_3=0; race5_4=0; end;
if race5=2 then do; race5_1=0; race5_2=1;  race5_3=0; race5_4=0; end;
if race5=3 then do; race5_1=0; race5_2=0;  race5_3=1; race5_4=0; end;
if race5=4 then do; race5_1=0; race5_2=0;  race5_3=0; race5_4=1; end;
if DMDEDUC2 in (7 9) then DMDEDUC2=.;
if DMDEDUC2 in (1 2) then educ4=0;
if DMDEDUC2=3        then educ4=1;
if DMDEDUC2=4        then educ4=2;
if DMDEDUC2=5        then educ4=3;

if educ4=0 then do; educ4_1=0; educ4_2=0; educ4_3=0;end;
if educ4=1 then do; educ4_1=1; educ4_2=0; educ4_3=0;end;
if educ4=2 then do; educ4_1=0; educ4_2=1; educ4_3=0;end;
if educ4=3 then do; educ4_1=0; educ4_2=0; educ4_3=1;end;
/* etc for the other blocks*/
run;

When your data sets get larger the repeated calls to reload the data set can add a lot of time to the execution. Disk input/output is one of the slowest thing that happens in computers these days. So you may not want to load the same data set multiple times for such.

 

When I look at your analysis code with this coupled with all those blocks of coding it appears that you are creating dummy variables. SAS will do that for you automatically if you place the variables on a CLASS statement

proc surveylogistic;
strata SDMVSTRA;
cluster SDMVPSU;
weight wtint4year;
domain include_highbloodp;
model highBP (event='1') = householdsmoking householdsmoker4_1 householdsmoker4_2 householdsmoker4_3 indoorsmokers4_1 indoorsmokers4_2 indoorsmokers4_3 dayssmokedinside8_1 dayssmokedinside8_2 dayssmokedinside8_3 dayssmokedinside8_4 dayssmokedinside8_5 dayssmokedinside8_6 dayssmokedinside8_7 sex2_1 race5_1 race5_2 race5_3 race5_4 
                          educ4_1 educ4_2 educ4_3 alc2_1 AGE /CLPARM VADJUST=none;
run; 

So it is quite likely that instead of educ4_1 educ4_2 educ4_3 on the Model statement you can use

Class Educ4.

 

You can specify a reference value as well such as

Class Educ4 (ref='0') ;

 

Your error message of All observations have the same response means that of the records used in the model they all have the same value for Highbp. So it is a data content error

Here is a small example to generate the same error that may be easier to see:

data junk;
  input resp indep;
datalines;
1   15
1   2
1   3
1   4
;

proc surveylogistic data=junk;
   model resp = indep;
run;

and the log shows:

260  proc surveylogistic data=junk;
261     model resp = indep;
262  run;

NOTE: Writing HTML Body file: sashtml.htm
ERROR: All observations have the same response.  No statistics are computed.
NOTE: The SAS System stopped processing this step because of errors.

I think that you want to go back to your data manipulation where you did this line:

if highBP=0 AND (highbloodpressure=. OR highbloodpressure2=. OR hypertensionmeds=. OR bpmedscurrent=.) then highBP=.;

and write the value to a different variable to see what you assigned. I have a sneaking suspicion that removed a lot of assigned values.

 

Unless you have a lot of text it best to just place the code directly into the message window. Open a text box or code box using either the </> or "running man" icon (the 7th and 8th icons from left to right) and paste the code. ANY questions about errors or messages the best practice is to copy the entire procedure code and the messages from the log and paste all that. We often see people post "code" in a message and then ask about an error or problem when the LOG pretty clearly shows the code actually run was not what they say. The text box maintains formatting so that diagnostic characters SAS often provides are displayed correctly. The message windows on this forum will reformat text.

 

Some other data issues.

I didn't see any code that combined data sets and adjusted the weight variable(s). Some of the statistics calculated by the survey procedures go to counts of population. If you combine multiple years of data and do not adjust the weights, not a trivial task, the population estimates will be roughly 4 times (2015, 2016, 2017 and 2018 = 4 collection cycles) as large as they should be.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 797 views
  • 0 likes
  • 3 in conversation