Create a data set consisting only of the Dinosaur BBQ locations in the state of New
York. Print and present your properly titled table.
@harveysarah0 wrote:
So I realized it's NY and not New York.
PROC print data= Bbq (where=(state='NY'))
By State;
Run;
Would this be correct?
You can try it and find out yourself. I don't know if it is correct because I don't have your data set.
spaces are not allowed in variable names in SAS. I suspect that 'New York' is a label.
Run the code below and check the actual variable name and use that instead.
proc contents data=Bbq;
run;
The actual variable name is State. But I would like just a table with New York so what would I need to add?
Ah ok. Then @PaigeMillers code is the way to go.
Perhaps this is what you want:
Proc sort data= Bbq(where=(state='New York')) out=bbq1;
By State;
Run;
Learning tip:
You need to understand the difference between a SAS variable in a data set (in this case the variable is STATE) and the value of the variable (in this case the value of the variable is 'New York'). These two things should not be confused. The BY statement wants the name of the variable (in this case STATE). The WHERE clause tells the PROC which values of STATE (in this case 'New York') are to be used by the procedure.
I have added the output data set BBQ1, as this is a good programming practice, which does not overwrite your original BBQ data set.
But going back to the original problem statement:
Create a data set consisting only of the Dinosaur BBQ locations in the state of New
York. Print and present your properly titled table.
It's not clear why you need PROC SORT here for this as no sorting was requested. PROC PRINT seems like all you need.
Thanks for your help. Why does this error come up when I try what you have?
NOTE: Input data set is already sorted, no sorting done.
NOTE: There were 0 observations read from the data set WORK.BBQ.
WHERE 0 /* an obviously FALSE WHERE clause */ ;
NOTE: The data set WORK.BBQ has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.15 seconds
cpu time 0.07 second
So we can't know what you did, unless you show us the ENTIRE log, not just the error messages.
Please help us by formatting the log properly. When you copy the log, please click on the {i} icon and paste the log into the window that appears. This will make the log readable. PLEASE DO NOT SKIP THIS STEP.
PROC PRINT data= Bbq (where=(state='New York'));
By State;
Run;
This is not the LOG. Please follow my instructions when you provide the entire LOG for this code.
69 PROC PRINT data= Bbq (where=(state='New York'));
70 By State;
71 Run;
NOTE: No observations in data set WORK.BBQ.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
72 Proc print data= Bbq(where=(state='New York')) out=bbq1;
---
22
76
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 76-322: Syntax error, statement will be ignored.
73 By State;
74 Run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.06 seconds
cpu time 0.04 seconds
75 Proc sort data= Bbq(where=(state='New York')) out=bbq1;
76 By State;
77 Run;
NOTE: Input data set is empty.
NOTE: The data set WORK.BBQ1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.09 seconds
cpu time 0.07 seconds
78 Proc sort data= Bbq (where=(state='New York')) out=bbq1;
79 By State;
80 Run;
NOTE: Input data set is empty.
NOTE: The data set WORK.BBQ1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.07 seconds
cpu time 0.04 seconds
Again I am not sure if I am doing this right. I am very new to this program.
Your data set BBQ is either empty, or it has no records for which STATE='New York'
You need to look at this data set and see what is in there.
So I realized it's NY and not New York.
PROC print data= Bbq (where=(state='NY'))
By State;
Run;
Would this be correct?
@harveysarah0 wrote:
So I realized it's NY and not New York.
PROC print data= Bbq (where=(state='NY'))
By State;
Run;
Would this be correct?
You can try it and find out yourself. I don't know if it is correct because I don't have your data set.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.