Libname mylib 'C:\STA575\SASData';
options nodate numberno;
proc print data=sashelp.prdsal2 nobs headers;
where country=Mexico;
var country year predict actual;
by country;
sum predict actual;
label predict='Predicted Sales' actual='Actual Sales';
title 'Predicted versus Actual Sales'
run;
Try to run it and look at the error messages (if any) that SAS generates.
Click SPOILER to expand.
1659 options nodate numberno; -------- 13 1660 proc print data=sashelp.prdsal2 nobs headers; ---- ------- 1 22 202 ERROR 13-12: Unrecognized SAS option name NUMBERNO. WARNING 1-322: Assuming the symbol NOOBS was misspelled as nobs. ERROR 22-322: Syntax error, expecting one of the following: ;, BLANKLINE, CONTENTS, DATA, DOUBLE, GRANDTOTAL_LABEL, GRANDTOT_LABEL, GRAND_LABEL, GTOTAL_LABEL, GTOT_LABEL, HEADING, LABEL, N, NOOBS, NOSUMLABEL, OBS, ROUND, ROWS, SPLIT, STYLE, SUMLABEL, UNIFORM, WIDTH. ERROR 202-322: The option or parameter is not recognized and will be ignored. 1661 where country=Mexico; ERROR: Variable Mexico is not on file SASHELP.PRDSAL2. 1662 var country year predict actual; 1663 by country; 1664 sum predict actual; 1665 label predict='Predicted Sales' actual='Actual Sales'; 1666 title 'Predicted versus Actual Sales' 1667 run; WARNING: The TITLE statement is ambiguous due to invalid options or unquoted text. 1668 1669 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
I don't think there is an option named NUMBERNO. There is an option named NUMBER which you can turn off by using NONUMBER (or NUMBER=0).
PROC PRINT does not have a NOBS option. Did you mean NOOBS?
PROC PRINT does not have a HEADERS option. Did you mean LABEL? Or perhaps SPLIT?
Does the dataset have a variable named COUNTRY and one another variable named MEXICO? And if it does what does it mean when they both contain the same value? Perhaps you wanted to instead check if the variable named COUNTRY as equal to the text string MEXICO? If so then you need to enclose the text literal in quotes so SAS knows it is not the name of a variable.
Do you actually want to the string run as part of the TITLE? If so then I would remove the line break and add an actual RUN statement to finish the PROC step. If not then make sure to end the TITLE statement with a semicolon.
Please post your SAS log. That will tell you where you have syntax errors.
One error is probably here
where country=Mexico;
which should say
where country='Mexico';
Also, I don't think there is a NOBS or a HEADERS option in PROC PRINT.
There may be other errors. From now on, when you get errors in your code, you need to show us the ENTIRE log for this DATA step or PROC. You need to copy the log as text and paste it into the window that appears when you click on the </> icon.
Libname mylib 'C:\STA575\SASData'; options nodate numberno; proc print data=sashelp.prdsal2 nobs headers; where country=Mexico; var country year predict actual; by country; sum predict actual; label predict='Predicted Sales' actual='Actual Sales'; title 'Predicted versus Actual Sales' run;
That should get you started.
Relevant links:
Try to run it and look at the error messages (if any) that SAS generates.
Click SPOILER to expand.
1659 options nodate numberno; -------- 13 1660 proc print data=sashelp.prdsal2 nobs headers; ---- ------- 1 22 202 ERROR 13-12: Unrecognized SAS option name NUMBERNO. WARNING 1-322: Assuming the symbol NOOBS was misspelled as nobs. ERROR 22-322: Syntax error, expecting one of the following: ;, BLANKLINE, CONTENTS, DATA, DOUBLE, GRANDTOTAL_LABEL, GRANDTOT_LABEL, GRAND_LABEL, GTOTAL_LABEL, GTOT_LABEL, HEADING, LABEL, N, NOOBS, NOSUMLABEL, OBS, ROUND, ROWS, SPLIT, STYLE, SUMLABEL, UNIFORM, WIDTH. ERROR 202-322: The option or parameter is not recognized and will be ignored. 1661 where country=Mexico; ERROR: Variable Mexico is not on file SASHELP.PRDSAL2. 1662 var country year predict actual; 1663 by country; 1664 sum predict actual; 1665 label predict='Predicted Sales' actual='Actual Sales'; 1666 title 'Predicted versus Actual Sales' 1667 run; WARNING: The TITLE statement is ambiguous due to invalid options or unquoted text. 1668 1669 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
I don't think there is an option named NUMBERNO. There is an option named NUMBER which you can turn off by using NONUMBER (or NUMBER=0).
PROC PRINT does not have a NOBS option. Did you mean NOOBS?
PROC PRINT does not have a HEADERS option. Did you mean LABEL? Or perhaps SPLIT?
Does the dataset have a variable named COUNTRY and one another variable named MEXICO? And if it does what does it mean when they both contain the same value? Perhaps you wanted to instead check if the variable named COUNTRY as equal to the text string MEXICO? If so then you need to enclose the text literal in quotes so SAS knows it is not the name of a variable.
Do you actually want to the string run as part of the TITLE? If so then I would remove the line break and add an actual RUN statement to finish the PROC step. If not then make sure to end the TITLE statement with a semicolon.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.