Learning SAS? Welcome to the exclusive online community for all SAS learners.

Does anyone know what I am doing wrong? I am unable to print the variable "mean."

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Does anyone know what I am doing wrong? I am unable to print the variable "mean."

Does anyone know what I am doing wrong? I am unable to print the variable "mean" but everything else seems to be working well.

 

I have attacehd a photo of my results. This is my code: 

 

DATA contest;
INFILE '/folders/myfolders/MyRawData/Pumpkin.dat';
INPUT Name $16. +1 Age 2. +1 Type $1. +1 Date MMDDYY10.
(Scr1, Scr2, Scr3, Scr4, Scr5) (4.1);
mean=mean(Scr1,Scr2,Scr3,Scr4,Scr5);
RUN;
PROC PRINT DATA=contest;
TITLE 'Pumpkin Carving Contest';
RUN;

 

Screen Shot 2016-06-15 at 5.55.58 PM.png


Accepted Solutions
Solution
‎06-16-2016 02:19 PM
Super User
Posts: 6,962

Re: Does anyone know what I am doing wrong? I am unable to print the variable "mean."

[ Edited ]

Omit the commas, and your input statement will be syntactically correct:

data contest;
input
  name $16. +1
  age 2. +1
  type $1. +1
  date MMDDYY10. +1
  (scr1 scr2 scr3 scr4 scr5) (4.1)
;
mean = mean(scr1,scr2,scr3,scr4,scr5);
cards;
Alicia Grossman  13 c 10/28/2012 7.8 6.5 7.2 8.0 7.9
;
run;

Oh, and your log tells you everything you need to know. The second WARNING implies that the existing dataset WORK.CONTEST was not replaced, and in that dataset variable mean is still missing.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Respected Advisor
Posts: 4,654

Re: Does anyone know what I am doing wrong? I am unable to print the variable "mean."

Should work. What does it say in the log?

PG
New Contributor
Posts: 4

Re: Does anyone know what I am doing wrong? I am unable to print the variable "mean."

Hello! Thank you for replying so quickly. 

When I tried to run it again just now, it won't show me the scr1-scr5 values in the table either.

 

This is what the log shows:

 

Screen Shot 2016-06-15 at 7.52.25 PM.png

Super User
Posts: 17,868

Re: Does anyone know what I am doing wrong? I am unable to print the variable "mean."

So basically you have a dataset named contest lying around thats being printed, not your data set that you're trying to read in. 

 

Fix your error to read in the data correctly and mean will print. 

 

 

Solution
‎06-16-2016 02:19 PM
Super User
Posts: 6,962

Re: Does anyone know what I am doing wrong? I am unable to print the variable "mean."

[ Edited ]

Omit the commas, and your input statement will be syntactically correct:

data contest;
input
  name $16. +1
  age 2. +1
  type $1. +1
  date MMDDYY10. +1
  (scr1 scr2 scr3 scr4 scr5) (4.1)
;
mean = mean(scr1,scr2,scr3,scr4,scr5);
cards;
Alicia Grossman  13 c 10/28/2012 7.8 6.5 7.2 8.0 7.9
;
run;

Oh, and your log tells you everything you need to know. The second WARNING implies that the existing dataset WORK.CONTEST was not replaced, and in that dataset variable mean is still missing.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 4

Re: Does anyone know what I am doing wrong? I am unable to print the variable "mean."

Thank you all so much for your responses.
KurtBremser, based on what you said I was able to successfully print. I appreciate it.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 516 views
  • 3 likes
  • 4 in conversation