I keep getting this error "ERROR: One or more variables are missing or freq or weight is zero on every observation." and I am not sure why.
data car;
input veh mpg @@;
cards;
1 26.5 1 23.5 1 26.5 1 23.5
2 24.5 2 22.5 2 26.0 2 25.0
3 27.5 3 27.5 3 32.5 3 33.5
4 30.5 4 28.5 4 30.0 4 28.5
5 20.5 5 21.5 5 25.0 5 25.0
6 26.5 6 23.5 6 26.0 6 27.0
7 29.0 7 27.5 7 30.0 7 35.0
8 26.5 8 27.0 8 28.5 8 32.0
;
proc glm;
class veh;
model mpg=veh/p;
means veh/hovtest=bartlett;
output out =car1 predicted =ypred residual=res;
run;
By any chance, is there a possibility of TAB characters between values?
Can you try EXPANDTABS option
data car;
infile cards expandtabs;
input veh mpg @@;
cards;
1 26.5 1 23.5 1 26.5 1 23.5
2 24.5 2 22.5 2 26.0 2 25.0
3 27.5 3 27.5 3 32.5 3 33.5
4 30.5 4 28.5 4 30.0 4 28.5
5 20.5 5 21.5 5 25.0 5 25.0
6 26.5 6 23.5 6 26.0 6 27.0
7 29.0 7 27.5 7 30.0 7 35.0
8 26.5 8 27.0 8 28.5 8 32.0
;
Please post your full log. Your code worked fine when i tested
data car;
input veh mpg @@;
cards;
1 26.5 1 23.5 1 26.5 1 23.5
2 24.5 2 22.5 2 26.0 2 25.0
3 27.5 3 27.5 3 32.5 3 33.5
4 30.5 4 28.5 4 30.0 4 28.5
5 20.5 5 21.5 5 25.0 5 25.0
6 26.5 6 23.5 6 26.0 6 27.0
7 29.0 7 27.5 7 30.0 7 35.0
8 26.5 8 27.0 8 28.5 8 32.0
;
proc glm;
class veh;
model mpg=veh/p;
means veh/hovtest=bartlett;
output out =car1 predicted =ypred residual=res;
run;
quit;
proc print noobs;run;
@novinosrin I still get the same error even when I copy and pasted what you did.
I attached the full log.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data car;
74 input veh mpg @@;
75 cards;
NOTE: Invalid data for veh in line 76 1-27.
NOTE: Invalid data for mpg in line 77 1-27.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
77 CHAR 2.24.5.2.22.5.2.26.0.2.25.0
ZONE 30332303033230303323030332322222222222222222222222222222222222222222222222222222
NUMR 2924E592922E592926E092925E000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
veh=. mpg=. _ERROR_=1 _N_=1
NOTE: Invalid data for veh in line 78 1-27.
NOTE: Invalid data for mpg in line 79 1-27.
79 CHAR 4.30.5.4.28.5.4.30.0.4.28.5
ZONE 30332303033230303323030332322222222222222222222222222222222222222222222222222222
NUMR 4930E594928E594930E094928E500000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
veh=. mpg=. _ERROR_=1 _N_=2
NOTE: Invalid data for veh in line 80 1-27.
NOTE: Invalid data for mpg in line 81 1-27.
81 CHAR 6.26.5.6.23.5.6.26.0.6.27.0
ZONE 30332303033230303323030332322222222222222222222222222222222222222222222222222222
NUMR 6926E596923E596926E096927E000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
veh=. mpg=. _ERROR_=1 _N_=3
NOTE: Invalid data for veh in line 82 1-27.
NOTE: Invalid data for mpg in line 83 1-27.
83 CHAR 8.26.5.8.27.0.8.28.5.8.32.0
ZONE 30332303033230303323030332322222222222222222222222222222222222222222222222222222
NUMR 8926E598927E098928E598932E000000000000000000000000000000000000000000000000000000
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
veh=. mpg=. _ERROR_=1 _N_=4
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.CAR has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
84 ;
85
86 proc glm;
87 class veh;
88 model mpg=veh/p;
89 means veh/hovtest=bartlett;
90 output out =car1 predicted =ypred residual=res;
91 run;
ERROR: One or more variables are missing or freq or weight is zero on every observation.
92 quit;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CAR1 may be incomplete. When this step was stopped there were 4 observations and 4 variables.
WARNING: Data set WORK.CAR1 was not replaced because this step was stopped.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
93
94
95
96 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
108
By any chance, is there a possibility of TAB characters between values?
Can you try EXPANDTABS option
data car;
infile cards expandtabs;
input veh mpg @@;
cards;
1 26.5 1 23.5 1 26.5 1 23.5
2 24.5 2 22.5 2 26.0 2 25.0
3 27.5 3 27.5 3 32.5 3 33.5
4 30.5 4 28.5 4 30.0 4 28.5
5 20.5 5 21.5 5 25.0 5 25.0
6 26.5 6 23.5 6 26.0 6 27.0
7 29.0 7 27.5 7 30.0 7 35.0
8 26.5 8 27.0 8 28.5 8 32.0
;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.