SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1655 views
  • 6 likes
  • 4 in conversation