Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- How to add more than one subgroup in proc gchart?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 01-02-2014 01:23 AM
(1673 views)

Hi,

I am new to SAS. It would be very great full if someone can help me to know how to pass more subgroup to a gchart in either of vbar or hbar option.

Thanks in Advance

Abhishek

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

OK.

So, in your data set, each row is a person.

For example, for row one, the person marked the highest value M1, then M5, then M6, and finally M22 without any further models.

The second person marked M1 as the highest, then M3, then M5, M21,M12, and M18.

Now,

you would like to plot this information, such that it shows for M1 there were 3 persons that find it highvalue (or whatever), for M5 there were 5 persons...for M67 there were 4.

So, your graph should have on the x-axis the Model number 1...70...

and the bars should be the number of people?

Am I getting this right?

Anca.

Here is code that would do what I said:

data have;

infile datalines missover;

input id Highvalue1 $ Highvalue2 $ highvalue3 $ highvalue4 $ highvalue5 $ highvalue6 $;

datalines;

1 m1 m5 m67 m22

2 m1 m3 m5 m21 m12 m18

3 m1 m23 m12 m45

4 m5 m10 m5 m22 m10 m67

5 m5 m6 m8 m56 m35

6 m5 m12 m45 m56

7 m37 m45 m56 m67 m70

8 m67 m70

;

proc transpose data = have out = have_t;

var highvalue:;

by id;

run;

proc sort data = have_t;by col1;run;

data have_2;

set have_t(where = (col1 ne " "));

by col1;

retain cnt 0;

if first.col1 then cnt = 1;

else cnt ++ 1;

if last.col1;

run;

proc gchart data = have_2;

vbar col1 / sumvar = cnt discrete;

run;quit;

Nachricht wurde geändert durch: Anca tilea

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi.

You can use the subgroup statement;

goptions reset = all;

axis1 label = none value = none;

proc gchart data = sashelp.shoes;

where region = "Africa";

vbar product/sumvar = stores group = subsidiary subgroup = product discrete

maxis = axis1;

run;quit;

Does this look like something you need?

Good luck,

Anca.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks Anca For the wonderful answer

Actually I am having a SAS dataset something like below:-

Highvalue1 Highvalue2 highvalue3 highvalue4 highvalue5 highvalue6

m1 m5 m67 m22

m1 m3 m5 m21 m12 m18

m1 m23 m12 m45

m5 m10 m5 m22 m10 m67

m5 m6 m8 m56 m35

m5 m12 m45 m56

m37 m45 m56 m67 m70

m67 m70

This table depicts the observation of the people who has given the highest marks to some of the models out of 75 models.

Now i want to plot the graph to representing the people who has given highest marks to m1 has also given to m5 m67 m22 and so on.

If somebody can help me out in this, that would be really appreciable.

Thanks in Advance,

Abhishek Pathak

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

OK.

So, in your data set, each row is a person.

For example, for row one, the person marked the highest value M1, then M5, then M6, and finally M22 without any further models.

The second person marked M1 as the highest, then M3, then M5, M21,M12, and M18.

Now,

you would like to plot this information, such that it shows for M1 there were 3 persons that find it highvalue (or whatever), for M5 there were 5 persons...for M67 there were 4.

So, your graph should have on the x-axis the Model number 1...70...

and the bars should be the number of people?

Am I getting this right?

Anca.

Here is code that would do what I said:

data have;

infile datalines missover;

input id Highvalue1 $ Highvalue2 $ highvalue3 $ highvalue4 $ highvalue5 $ highvalue6 $;

datalines;

1 m1 m5 m67 m22

2 m1 m3 m5 m21 m12 m18

3 m1 m23 m12 m45

4 m5 m10 m5 m22 m10 m67

5 m5 m6 m8 m56 m35

6 m5 m12 m45 m56

7 m37 m45 m56 m67 m70

8 m67 m70

;

proc transpose data = have out = have_t;

var highvalue:;

by id;

run;

proc sort data = have_t;by col1;run;

data have_2;

set have_t(where = (col1 ne " "));

by col1;

retain cnt 0;

if first.col1 then cnt = 1;

else cnt ++ 1;

if last.col1;

run;

proc gchart data = have_2;

vbar col1 / sumvar = cnt discrete;

run;quit;

Nachricht wurde geändert durch: Anca tilea

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks anca, It was very helpful for me

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!

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.