BookmarkSubscribeRSS Feed
Alexxxxxxx
Pyrite | Level 9

Dear all,

 

for the .excel file in the attachment, how to create the line chart of each "person_ctry_code" group, which just like the following picture?

The Y-axis is the no_app_per_year and no_app_per_year;

the X-axis is the years from 1990 to 2012.

Screenshot (6).png

9 REPLIES 9
PaigeMiller
Diamond | Level 26

Use PROC SGPLOT with the SERIES statement and the GROUP= option.

--
Paige Miller
Reeza
Super User

https://documentation.sas.com/?docsetId=grstatproc&docsetVersion=9.4&docsetTarget=n06fb9ichgg6akn180...

Instead of SCATTER use SERIES but the rest is the same.

 


@Alexxxxxxx wrote:

Dear all,

 

for the .excel file in the attachment, how to create the line chart of each "person_ctry_code" group, which just like the following picture?

The Y-axis is the no_app_per_year and no_app_per_year;

the X-axis is the years from 1990 to 2012.

Screenshot (6).png


 

Alexxxxxxx
Pyrite | Level 9

thanks for your suggestion.

however, when I use 

 

 

proc sgplot data=Results.PATSTAT_no_full_hrm_with_ctry5;
   SERIES x=year y=no_app_per_year / group=person_ctry_code;
   SERIES x=year y=no_cit_per_year / group=person_ctry_code;
run;

all the lines are shown in one picture.

Screenshot (8).png

Could you please give me more suggestions about this?

Reeza
Super User
For the split within a single graph you put the variable in the GROUP = section.
For splitting it to mulitple graphs, put that variable in the BY statement instead.

You don't provide data so we're kinda guessing here.

proc sgplot data=have;
by var_for _each graph;
series x= year y=no_cit_per_year / group = person_ctry_code;
run;

If you want multiple graphs with different variables it's probably easiest to use multiple SGPLOT statements or restructure your data to support the BY processing.
Alexxxxxxx
Pyrite | Level 9

the file is added in the attachment. please have a look.

 

besides, by using the code 

 

proc sgplot data=Results.PATSTAT_no_full_hrm_with_ctry5;
by person_ctry_code;
series x= year y=no_app_per_year / group = person_ctry_code;
series x= year y=no_cit_per_year / group = person_ctry_code;
run;

I get a serious picture like 

 

Screenshot (10).png

it looks much better now,

however, I expect to get a picture of each "person_ctry_cod" and for each picture, there are two lines, one is the no_app_per_year, one is no_cit_per_year. for current picture, the explanation of line and Y-axis are wrong.

Could you please give me some suggestions about this?

thanks in advance

 

Reeza
Super User
Remove the GROUP variable entirely.
Alexxxxxxx
Pyrite | Level 9

Thanks,

 

now I get a serious picture like

Screenshot (13).png

Is there any method to put them together like the Figure2.1,

and

1.delete the explanation at the Y-axis

2. replace ALL with no_app_per_year, replace By corporation with no_cit_per_year,

3. replace "PERSON_CTRY_CODE=AT" with "AT"?

WeChat Image_20191119230846.png

Sorry, I have a lot of questions. I just start to learn how to use SAS to draw the line chart

Reeza
Super User
You really should start with what you have and what you want. Use SGPANEL for this type of graph.
Not sure how the legend part would work you'll need to customize that with keylegend.

Ksharp
Super User

Heat Map ?

 

x.png

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 9 replies
  • 1106 views
  • 6 likes
  • 4 in conversation