BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
emmad511
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

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;

View solution in original post

2 REPLIES 2
japelin
Rhodochrosite | Level 12

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;
ballardw
Super User

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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 526 views
  • 2 likes
  • 3 in conversation