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

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
AncaTilea
Pyrite | Level 9

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

View solution in original post

4 REPLIES 4
AncaTilea
Pyrite | Level 9

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.

Pathak
Calcite | Level 5

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

AncaTilea
Pyrite | Level 9

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

Pathak
Calcite | Level 5

Thanks anca, It was very helpful for me

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 1282 views
  • 0 likes
  • 2 in conversation