I run my code as follows:
data nh.outcomes_joint_wkd_ind;
set nh.outcomes_joint_wkd_ind;
if alpha50=. then eligible=2;
else eligible=1;
run;
***SLR;
PROC SURVEYREG DATA=nh.outcomes_joint_wkd_ind nomcar;
STRATA sdmvstra;
CLUSTER sdmvpsu;
CLASS alpha50;
WEIGHT glucwt4yr;
domain eligible;
model BMXBMI=alpha50/adjrsq clparm solution vadjust=none;
lsmeans alpha50/ lines adjust=tukey;
run;
***** MLR;
PROC SURVEYREG DATA=nh.outcomes_joint_wkd_ind nomcar;
STRATA sdmvstra;
CLUSTER sdmvpsu;
CLASS alpha50 age RIAGENDR PIR SDDSRVYR RIDRETH1;
WEIGHT glucwt4yr;
DOMAIN eligible;
model BMXBMI= age RIAGENDR PIR SDDSRVYR RIDRETH1 EIEER alpha50/adjrsq clparm solution vadjust=none;
lsmeans / lines adjust=tukey;
run;
But the log told me that for SLR: All observations were omitted due to missing values or non-positive weights in domain eligible=2.
For MLR: No observations in data set OUTCOMES_JOINT_WKD_IND.
I also checked the data set, and it contains 20470 observations. I know there is something wrong with my code, but I don't know where and how. So can you point out where I was wrong and howto fix it?
Thank you so much!
All observations were omitted due to missing values or non-positive weights in domain eligible=2.
I think this means that because of missing values or non-positive weights, the PROC SURVEYREG procedure cannot operate. ^You need to check your dataset for these problems.
No observations in data set OUTCOMES_JOINT_WKD_IND.
I also checked the data set, and it contains 20470 observations
What data set are you referring to that you checked and it contains 20470 observations? When SAS says the data set has no observations and the user says it has 20470, I believe SAS. So, please convince us that data set nh.outcomes_joint_wkd_ind has that many observations, by running PROC CONTENTS and showing us the top 10 lines or so.
Also, @knighsson, from now on we need to see the entire log for these steps ... the code, the NOTES, the WARNINGS, the errors, in other words everything in the log for these steps.
Thank you for your respond, I would also trust SAS more than myself! I think something wrong with the eligible domain maybe. I attached the screen shots
One: Please post log entries as text. Copy the text from the log and paste into a code box opened on the forum with the </> icon.
That way we can copy bits of the code and make suggested changes or simply highlight text. I know that I am not going to retype, very likely introducing new problems, lots of someone else's code.
Two: That short proc print output showing missing values for so many variables but not showing any of the variables actually used by your code does question the completeness of the data involved.
In your code you use if alpha50=. then eligible=2;
data nh.outcomes_joint_wkd_ind;
set nh.outcomes_joint_wkd_ind;
if alpha50=. then eligible=2;
else eligible=1;
run;
So I guess that means alpha50 is always missing for eligible=2.
And then your SurveyReg code uses alpha50 - which is always missing for eligible=2:
CLASS alpha50 age RIAGENDR PIR SDDSRVYR RIDRETH1;
WEIGHT glucwt4yr;
DOMAIN eligible;
model BMXBMI= age RIAGENDR PIR SDDSRVYR RIDRETH1 EIEER alpha50/adjrsq clparm solution vadjust=none;
Isn't that then exactly what the SAS Log tells you?
All observations were omitted due to missing values or non-positive weights in domain eligible=2
That's very odd. Doesn't make sense to me. But you still need to fix this missing value problem and negative weight problem, and then perhaps the problem will go away.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.