turn on suggestions

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

Showing results for

Find a Community

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

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-02-2014 01:23 AM

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

Accepted Solutions

Solution

01-03-2014
10:38 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Pathak

01-03-2014 10:38 AM

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

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Pathak

01-02-2014 07:37 AM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AncaTilea

01-02-2014 10:45 PM

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

Solution

01-03-2014
10:38 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Pathak

01-03-2014 10:38 AM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AncaTilea

01-06-2014 01:43 AM

Thanks anca, It was very helpful for me