BookmarkSubscribeRSS Feed
JoshuaG
Calcite | Level 5

Hi, I am trying to complete a HW assignment and I keep getting a blank table for the question 6. What am I doing wrong to make the table not show? Find attached a few screenshots of the situation.Screenshot (1091).pngScreenshot (1090).pngScreenshot (1089).png

8 REPLIES 8
ballardw
Super User

What does your log show?

 

It is best to paste code and/or log information into a text box opened on the forum with the </>. Copy text and paste. That way if we see something that needs correction it is much easier to edit than to retype from scratch. (I'm not the only one lazy that way.)

 

Since you have 4 procedure calls that could create a table, Proc Contents, Proc Print and two calls to Proc Means you really need to state explicitly which you are having problems with.

 

 

JoshuaG
Calcite | Level 5
/* S325 HW 1
By Joshua Gataric
9/1/2022
*/

data bmi;
infile '/home/u62108616/S325/hw1.dat';
input Id age Height Weight Gender;
run;

/* 54 observations in the log file */

proc contents data = bmi;
run;

proc print data = bmi;
title1 'BMI Data for senior people';
title2 'by Alva Hospital';
run;

title 'By Alva Hospital';
run;

proc means data = bmi maxdec = 4;
var Weight Height; 
run; 

proc means data = bmi;
class Gender;
var age Weight Height;
run;

JoshuaG
Calcite | Level 5
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 /* S325 HW 1
70 By Joshua Gataric
71 9/1/2022
72 */
73
74 data bmi;
75 infile '/home/u62108616/S325/hw1.dat';
76 input Id age Height Weight Gender;
77 run;
 
NOTE: The infile '/home/u62108616/S325/hw1.dat' is:
Filename=/home/u62108616/S325/hw1.dat,
Owner Name=u62108616,Group Name=oda,
Access Permission=-rw-r--r--,
Last Modified=01Sep2022:18:55:29,
File Size (bytes)=2118
 
NOTE: Invalid data for Gender in line 1 33-36.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1 10001 61 236.00 74.50 Male 36
Id=10001 age=61 Height=236 Weight=74.5 Gender=. _ERROR_=1 _N_=1
NOTE: Invalid data for Gender in line 2 33-38.
2 10002 55 141.00 69.00 Female 38
Id=10002 age=55 Height=141 Weight=69 Gender=. _ERROR_=1 _N_=2
NOTE: Invalid data for Gender in line 3 33-38.
3 10003 89 109.50 62.00 Female 38
Id=10003 age=89 Height=109.5 Weight=62 Gender=. _ERROR_=1 _N_=3
NOTE: Invalid data for Gender in line 4 33-36.
4 10004 73 172.00 64.00 Male 36
Id=10004 age=73 Height=172 Weight=64 Gender=. _ERROR_=1 _N_=4
NOTE: Invalid data for Gender in line 5 33-38.
5 10005 80 124.50 63.00 Female 38
Id=10005 age=80 Height=124.5 Weight=63 Gender=. _ERROR_=1 _N_=5
NOTE: Invalid data for Gender in line 6 33-38.
6 10006 58 176.25 63.25 Female 38
Id=10006 age=58 Height=176.25 Weight=63.25 Gender=. _ERROR_=1 _N_=6
NOTE: Invalid data for Gender in line 7 33-38.
7 10007 79 131.50 60.25 Female 38
Id=10007 age=79 Height=131.5 Weight=60.25 Gender=. _ERROR_=1 _N_=7
NOTE: Invalid data for Gender in line 8 33-36.
8 10008 78 207.00 69.00 Male 36
Id=10008 age=78 Height=207 Weight=69 Gender=. _ERROR_=1 _N_=8
NOTE: Invalid data for Gender in line 9 33-38.
9 10009 75 149.50 62.50 Female 38
Id=10009 age=75 Height=149.5 Weight=62.5 Gender=. _ERROR_=1 _N_=9
NOTE: Invalid data for Gender in line 10 33-36.
10 10010 80 164.00 70.50 Male 36
Id=10010 age=80 Height=164 Weight=70.5 Gender=. _ERROR_=1 _N_=10
NOTE: Invalid data for Gender in line 11 33-36.
11 10011 63 193.75 69.00 Male 36
Id=10011 age=63 Height=193.75 Weight=69 Gender=. _ERROR_=1 _N_=11
NOTE: Invalid data for Gender in line 12 33-38.
12 10012 63 246.00 63.25 Female 38
Id=10012 age=63 Height=246 Weight=63.25 Gender=. _ERROR_=1 _N_=12
NOTE: Invalid data for Gender in line 13 33-36.
13 10013 76 169.00 72.50 Male 36
Id=10013 age=76 Height=169 Weight=72.5 Gender=. _ERROR_=1 _N_=13
NOTE: Invalid data for Gender in line 14 33-38.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
14 10014 73 143.00 62.00 Female 38
Id=10014 age=73 Height=143 Weight=62 Gender=. _ERROR_=1 _N_=14
NOTE: Invalid data for Gender in line 15 33-36.
15 10015 76 180.25 70.50 Male 36
Id=10015 age=76 Height=180.25 Weight=70.5 Gender=. _ERROR_=1 _N_=15
NOTE: Invalid data for Gender in line 16 33-38.
16 10016 75 136.50 63.75 Female 38
Id=10016 age=75 Height=136.5 Weight=63.75 Gender=. _ERROR_=1 _N_=16
NOTE: Invalid data for Gender in line 17 33-38.
17 10017 85 115.00 62.75 Female 38
Id=10017 age=85 Height=115 Weight=62.75 Gender=. _ERROR_=1 _N_=17
NOTE: Invalid data for Gender in line 18 33-36.
18 10018 82 171.00 69.50 Male 36
Id=10018 age=82 Height=171 Weight=69.5 Gender=. _ERROR_=1 _N_=18
NOTE: Invalid data for Gender in line 19 33-38.
19 10019 86 139.00 61.75 Female 38
Id=10019 age=86 Height=139 Weight=61.75 Gender=. _ERROR_=1 _N_=19
NOTE: Invalid data for Gender in line 20 33-38.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
20 10020 85 125.50 62.00 Female 38
Id=10020 age=85 Height=125.5 Weight=62 Gender=. _ERROR_=1 _N_=20
NOTE: 54 records were read from the infile '/home/u62108616/S325/hw1.dat'.
The minimum record length was 36.
The maximum record length was 38.
NOTE: The data set WORK.BMI has 54 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 760.62k
OS Memory 25764.00k
Timestamp 09/02/2022 03:22:37 PM
Step Count 40 Switch Count 2
Page Faults 0
Page Reclaims 135
Page Swaps 0
Voluntary Context Switches 19
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272
 
 
78
79 /* 54 observations in the log file */
80
81 proc contents data = bmi;
82 run;
 
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.03 seconds
user cpu time 0.04 seconds
system cpu time 0.00 seconds
memory 1723.65k
OS Memory 26024.00k
Timestamp 09/02/2022 03:22:37 PM
Step Count 41 Switch Count 0
Page Faults 0
Page Reclaims 149
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 16
 
 
83
84 proc print data = bmi;
85 title1 'BMI Data for senior people';
86 title2 'by Alva Hospital';
87 run;
 
NOTE: There were 54 observations read from the data set WORK.BMI.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.06 seconds
user cpu time 0.07 seconds
system cpu time 0.00 seconds
memory 829.62k
OS Memory 26020.00k
Timestamp 09/02/2022 03:22:37 PM
Step Count 42 Switch Count 2
Page Faults 0
Page Reclaims 73
Page Swaps 0
Voluntary Context Switches 21
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 32
 
 
88
89 title 'By Alva Hospital';
90 run;
91
92 proc means data = bmi;
93 var Weight Height;
94 run;
 
NOTE: There were 54 observations read from the data set WORK.BMI.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.02 seconds
user cpu time 0.02 seconds
system cpu time 0.01 seconds
memory 6686.18k
OS Memory 31928.00k
Timestamp 09/02/2022 03:22:37 PM
Step Count 43 Switch Count 1
Page Faults 0
Page Reclaims 1565
Page Swaps 0
Voluntary Context Switches 19
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
95
96 proc means data = bmi;
97 class Gender;
98 var age Weight Height;
99 run;
 
WARNING: A class or frequency variable is missing on every observation.
NOTE: There were 54 observations read from the data set WORK.BMI.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 7619.50k
OS Memory 33208.00k
Timestamp 09/02/2022 03:22:37 PM
Step Count 44 Switch Count 1
Page Faults 0
Page Reclaims 1632
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
 
 
100
101
102
103 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
113
 
User: u62108616
Messages: 3
 
 
 
 
 
 
 
 
ballardw
Super User

The reason that last proc means generated no results is in the log

96 proc means data = bmi;
97 class Gender;
98 var age Weight Height;
99 run;
 
WARNING: A class or frequency variable is missing on every observation.
NOTE: There were 54 observations read from the data set WORK.BMI.
NOTE: PROCEDURE MEANS used (Total process time):

If you look above when you read the data you have attempted to read Gender as a numeric value and SAS told you that was a problem:

NOTE: Invalid data for Gender in line 1 33-36.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1 10001 61 236.00 74.50 Male 36
Id=10001 age=61 Height=236 Weight=74.5 Gender=. _ERROR_=1 _N_=1
NOTE: Invalid data for Gender in line 2 33-38.
2 10002 55 141.00 69.00 Female 38
Id=10002 age=55 Height=141 Weight=69 Gender=. _ERROR_=1 _N_=2
NOTE: Invalid data for Gender in line 3 33-38.

The Rule line allows you to count spaces when pasted as text directly from the log into a text box. Since you did not do that the message window removed some of the spaces so that the 10001 does not appear under the first -.

You Gender values are Character, Male and Female.

Your input statement does not indicate that Gender should be read as character. Use

 input Id age Height Weight Gender $;

in the first data step and that should fix the problem. The $ tells SAS that Gender should be read as character and will default to 8 characters in length, which should be long enough to hold values of Female and Male. If you have other values longer than 8 characters you need to specify an informat that would read longer values. Example that would read up to 15 characters. The : helps align data of different lengths in this case.

 input Id age Height Weight Gender : $15. ;

 

tom_grant
SAS Super FREQ

You may want to also check the order of the variables you are reading in the .dat file, not sure of the what units they are measured in but the values for height look a little suspicious.

 

for example is the Height value for the first record really 236?

1 10001 61 236.00 74.50 Male 36
Id=10001 age=61 Height=236 Weight=74.5 Gender=. _ERROR_=1 _N_=1

Also there seems to be a variable at the end of each record (ex. the value of 36 for the first record) - again not sure what this is & maybe it is not important & was intentionally not read in.

JoshuaG
Calcite | Level 5

Not treating Gender as a character was indeed it. Now for question 7, is this what I am supposed to do?

proc print data = bmi(obs=20);
proc means data = bmi maxdec = 3;
class Gender;
var age Weight Height;
run;

Screenshot (1092).png

ballardw
Super User

I don't know your instructor. It may be that the Proc means should use the same observations as the Proc Print did.

 

Sometimes half of a problem is determining what your instructor means.

 


@JoshuaG wrote:

Not treating Gender as a character was indeed it. Now for question 7, is this what I am supposed to do?

proc print data = bmi(obs=20);
proc means data = bmi maxdec = 3;
class Gender;
var age Weight Height;
run;

Screenshot (1092).png


 

Tom
Super User Tom
Super User

@tom_grant wrote:

You may want to also check the order of the variables you are reading in the .dat file, not sure of the what units they are measured in but the values for height look a little suspicious.

 

for example is the Height value for the first record really 236?

1 10001 61 236.00 74.50 Male 36
Id=10001 age=61 Height=236 Weight=74.5 Gender=. _ERROR_=1 _N_=1

Also there seems to be a variable at the end of each record (ex. the value of 36 for the first record) - again not sure what this is & maybe it is not important & was intentionally not read in.


The number at the end of each line is the length of that line.  Since the error message said the value read for GENDER in columns 33 to 36 was not a valid number then the e in Male is the last character on that line.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 1097 views
  • 0 likes
  • 4 in conversation