I am getting an error on my code and I cannot figure out what is wrong with it. The error is keeping the code under Item 5 is not showing up in my results either. Any help would would be amazing.
/* Item 1 */
PROC IMPORT
DATAFILE='/home/u45048482/sasuser.v94/LM2/FantasyBaseball2.csv'
DBMS=csv REPLACE OUT=FANTASY;
GETNAMES=YES;
RUN;
/* Item 2 */
PROC FORMAT;
VALUE Personinitial 1 = "DJ"
2 = "AR"
3 = "BK"
4 = "JW"
5 = "TS"
6 = "RL"
7 = "DR"
8 = "MF";
DATA FANTASY;
SET FANTASY;
SqrtTime = SQRT(TIME);
label Time = 'Time to make Selection (in seconds)'
Person = 'Person making selection';
SqrtTime = 'Square root of time (in seconds) to make selection';
format person Personinitial.;
/* Item 3 */
PROC SGPLOT data=FANTASY;
vbox time / group=person;
title "Comparison Boxplot: Times per Person";
title2 'Ian Conley';
RUN;
PROC MEANS data=fantasy n min max mean std median skewness kurtosis;
TITLE "Summary Statistics: Times per Person";
TITLE2 "Ian Conley";
var time;
Class person;
RUN;
/* Item 4 */
ods graphics on;
PROC GLM data=fantasy plots=diagnostics;
class person;
model time = person;
means person / BON cldiff lines;
title 'ANOVA Model: Times = Person';
title2'Ian Conley';
RUN;
/* Item 5 */
PROC MEANS data=fantasy n min max mean std median skewness kurtosis maxdec=3;
TITLE "Summary Statistics: SqrtTime per Person";
TITLE2 "Ian Conley";
var sqrtTime;
Class person;
RUN;
ods graphics on;
PROC GLM data=fantasy plots=diagnostics;
class person;
model SqrtTime = person;
means person / BON cldiff lines;
title 'ANOVA Model: SqrtTime = Person';
title2'Ian Conley';
RUN; QUIT;
This is the Log file for the code as well
First suggestion until you are more comfortable with SAS coding:
No not use this type of coding:
120 DATA FANTASY; 121 SET FANTASY;
When you do that the source data set is completely replaced. So some logic errors can destroy way too much data.
Second, paste LOG and code in text boxes opened on the forum with the </>. The message windows reformat text moving some of the diagnostic characters that SAS provides for some messages in the log.
If these are all supposed to be labels:
123 label Time = 'Time to make Selection (in seconds)' 124 Person = 'Person making selection'; 125 SqrtTime = 'Square root of time (in seconds) to make selection';
Then use only ONE semicolon at the end of all the labels:
label Time = 'Time to make Selection (in seconds)' Person = 'Person making selection' SqrtTime = 'Square root of time (in seconds) to make selection' ;
Or use label with each variable
label Time = 'Time to make Selection (in seconds)' ; label Person = 'Person making selection' ; label SqrtTime = 'Square root of time (in seconds) to make selection' ;
You were getting a lot of errors because as posted you are assigning a text value to a numeric variable (SQRTTIME).
Which means that a missing value was set for SQRTTIMEbecause SAS will not let you place text, that can't be converted into a number easily, into a numeric variable. So when you use that SQRTTIME variable in the model it is missing.
Hello @conleyi and welcome to the SAS Support Communities!
A proven debugging strategy is to start with the first error message (or warning or suspicious note) in the log because that is often the root cause of subsequent errors. In your case the series of notes "Invalid numeric data ..." after the DATA step under "Item 2" is suspicious. Indeed, the text string 'Square root of time (in seconds) to make selection' mentioned in the log is an invalid value for a numeric variable. Which numeric variable? See line number 125 in the log: An attempt is made to assign that character value to numeric variable SqrtTime. But isn't that "assignment" just a part of the LABEL statement? No, it isn't: The LABEL statement ends prematurely due to an unwanted semicolon after 'Person making selection'! Could this be the root cause of the error later on in the PROC GLM step under "Item 5"? Yes, all values of SqrtTime were overwritten with missing values (as documented in the log: SqrtTime=.) so the dependent variable in the MODEL statement is now missing "on every observation" as the log criticizes.
So, deleting the semicolon in the middle of the LABEL statement should help a lot.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.