BookmarkSubscribeRSS Feed
fawink
Calcite | Level 5

Dear people

 

I am currently working on my master thesis with SAS and want to calculate a GLM. My goal is to check, which RK have an influence of the result in RKSchu.

 

I wrote this code: 

 

DATA Allehypo Verurteilte Freigesprochen Lebend Todesstrafe Teil1 Teil2;
SET MASTER.SERIE3HYPO MASTER.SERIE3RK;

PROC GLM;
CLASS RKSchu;
MODEL RKSchu = RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17;

 

But I allay get the following error: 

ERROR: One or more variables are missing or freq or weight is zero on every observation.
 
Someone around who could help me with this?
 
Thank you in advance and best regards from Switzerland!
12 REPLIES 12
PaigeMiller
Diamond | Level 26

@fawink wrote:

 

ERROR: One or more variables are missing or freq or weight is zero on every observation.
 

Actually look at your data. Then the meaning of the error message ought to be clear. At least one of your variables is all missing.

 

Also, your code is poorly written, when you write this DATA statement, you create seven data sets at once, they are identical to each other, and there's no reason to do this.

 

DATA Allehypo Verurteilte Freigesprochen Lebend Todesstrafe Teil1 Teil2;
SET MASTER.SERIE3HYPO MASTER.SERIE3RK;

PROC GLM;

 

--
Paige Miller
fawink
Calcite | Level 5

Thank you for your reply. 

 

I changed the code to:


DATA WORK.ALLERK ;
SET WORK.ALLERK ;

PROC GLM;
CLASS RKSchu ;
MODEL RKSchu = RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17;

 

I still get the same Error Report. 

 

Where should my variables be missing? They are in the file WORK.ALLERK.

 

I'm sorry if I can't explain myself very clearly, English isn't my first language...

ballardw
Super User

@fawink wrote:

Thank you for your reply. 

 

I changed the code to:


DATA WORK.ALLERK ;
SET WORK.ALLERK ;

PROC GLM;
CLASS RKSchu ;
MODEL RKSchu = RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17;

 

I still get the same Error Report. 

 

Where should my variables be missing? They are in the file WORK.ALLERK.

 

I'm sorry if I can't explain myself very clearly, English isn't my first language...


Please post the log with the code and the errors. Paste the lines copied from the log into a code box opened using the forum's {I} menu icon to preserve error text formatting. The message boxes here will reformat text moving error diagnostic characters.

fawink
Calcite | Level 5

Thank you, this is the complete log: 

 75         
 76         DATA  WORK.ALLERK ;
 77         SET     WORK.ALLERK ;
 78         
 
 NOTE: There were 2280 observations read from the data set WORK.ALLERK.
 NOTE: The data set WORK.ALLERK has 2280 observations and 110 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.01 seconds
       cpu time            0.01 seconds
       
 
 79         PROC GLM;
 80         CLASS RKSchu ;
 81         MODEL RKSchu = RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17;
 82         
 83         
 84         
 85         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 ERROR: One or more variables are missing or freq or weight is zero on every observation.
 98         
PaigeMiller
Diamond | Level 26

@fawink wrote:

Thank you for your reply. 

 

I changed the code to:


DATA WORK.ALLERK ;
SET WORK.ALLERK ;

PROC GLM;
CLASS RKSchu ;
MODEL RKSchu = RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17;

 

I still get the same Error Report. 

 

Where should my variables be missing? They are in the file WORK.ALLERK.

 

I'm sorry if I can't explain myself very clearly, English isn't my first language...


 

 

You didn't do the first thing I said to do.

 

Actually look at your data. Look at work.allerk. What do you see? Is one of the variable all missing?

--
Paige Miller
fawink
Calcite | Level 5
All the variables in the code are also in the work.allerk data file. And they all have a value. That's why I'm so clueless about what to do.
Reeza
Super User

Run the following and post the output please, it will show how many missings you actually have in your data.

 

proc format ;
	value $ missfmt ' '="Missing" other="Not Missing";
	value nmissfmt .="Missing" other="Not Missing";
run;

*Proc freq to count missing/non missing;
ods table onewayfreqs=temp;

proc freq data=allerk;
	table _all_ / missing;
	format _numeric_ nmissfmt. _character_ $missfmt.;
run;

*Format output;

data long;
	length variable $32. variable_value $50.;
	set temp;
	Variable=scan(table, 2);
	Variable_Value=strip(trim(vvaluex(variable)));
	presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
	keep variable variable_value frequency percent cum: presentation;
	label variable='Variable' variable_value='Variable Value';
run;

proc sort data=long;
	by variable;
run;

proc transpose data=long out=want;
	by variable;
	id variable_value;
	var presentation;
run;

proc print data=want;
run;

Post the results from the WANT data set. 

 

Note that your GLM statement doesn't point to a data set whichcould be problematic if you're not always running your code from the start. The same with using the same data set name in the DATA and SET statement.

 

data allwerk; *<- if there is a mistake in this step it can destroy your original data and then you'll get errors;
set allwerk;


proc glm; *NO DATA= statement????;
fawink
Calcite | Level 5

Thank you soooo, sooo much, I think I found the mistake. There really is a lot of data missing. 

 

 

When I checked the data again, I found that every person has 10 lines, like this:

 

 

I assume thats where the error comes from, because very person should just have one line, right?

 

I got this data from my tutor. Any tips how I can just 'delete' the other lines?

Reeza
Super User

It depends, but cleaning the data is an import step that should never be skipped.

 

First run a PROC FREQ without the formats I have and PROC MEANS and examine your data thoroughly. 

Depending on your data you may need to combine rows rather than just delete rows, unless for some reason all the data in those rows is missing. You can use CMISS and NMISS to count missing values.

 

Reeza
Super User

You're running a GLM model with a categorical outcome?

 

I don't think that's correct, you likely should be using a different type of analysis. 

 


@fawink wrote:

Dear people

 

I am currently working on my master thesis with SAS and want to calculate a GLM. My goal is to check, which RK have an influence of the result in RKSchu.

 

I wrote this code: 

 

DATA Allehypo Verurteilte Freigesprochen Lebend Todesstrafe Teil1 Teil2;
SET MASTER.SERIE3HYPO MASTER.SERIE3RK;

PROC GLM;
CLASS RKSchu;
MODEL RKSchu = RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17;

 

But I allay get the following error: 

ERROR: One or more variables are missing or freq or weight is zero on every observation.
 
Someone around who could help me with this?
 
Thank you in advance and best regards from Switzerland!

 

fawink
Calcite | Level 5
Thank you for your input, Reza. What would be my alternative?

I'm sorry for the question, but statistics is not my strength...
ballardw
Super User

Are your RK1 RK3 RK4 RK5 RK6 RK7 RK8 RK9 RK11 RK12 RK13 RK17 variables measurements from different time periods, different locations/plots/samples or similar? Is it possible that the "missing" values were something like a zero value that was not recorded?

Or can you describe why you have so many missing values?

 

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 12 replies
  • 2929 views
  • 0 likes
  • 4 in conversation