Hello! I have a problem in which I need to use PROC SGPANEL to create a vertical bar graph of UFO physical encounters (physical) by location with the panels being separated by the years 1987 and 1988 (in that order).
Here's what I have so far:
/* Read the data into SAS */
proc import
out = ufo
datafile = '/folders/myfolders/sasuser.v94/all_data/extdata/UFO.csv'
dbms = CSV replace;
getnames = YES;
run;
proc print data=ufo;
run;
proc sgpanel data=ufo;
title 'UFO physical encounters by Location for 1987 and 1988';
panelby 1987 1988;
vbar Physical Location;
run;
I'm not very familiar with the proc sgpanel syntax. Could someone please help? Thanks in advance!
Is it like this?
proc sgpanel data=ufo(where=(Physical=1 and year in (1987,1988)));
title 'UFO physical encounters by Location for 1987 and 1988';
panelby year;
vbar location;
run;
Is it like this?
proc sgpanel data=ufo(where=(Physical=1 and year in (1987,1988)));
title 'UFO physical encounters by Location for 1987 and 1988';
panelby year;
vbar location;
run;
The errors you see in your log (you did look at the log didn't you?) are because the Panelby statement expects to have one or more variable names, not values, just like any other BY statement.
To subset data to a specific range of values you would use a WHERE statement.
proc sgpanel data=ufo;
title 'UFO physical encounters by Location for 1987 and 1988';
where year in ( 1987 1988);
panelby year;
vbar Physical Location;
run;
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.