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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.