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

Hi,

i would like to generate the vbar with proc gchart where i would like to display the blank vbar for those which are not there in data. For example, from the below data i will get the vbar char for india, japan, usa, china depending upon the number of records there are in the data, however i will need to display atleast in the label on maxis other countries but with no vbar as those countries records are not in the data. like i  need to display korea in maxis label but no vbar.

data have;

input countrycd country$;

cards;

1  india

1 india

1 india

1 india

2 japan

2 japan

3 usa

4 china

4 china

4 china

;

run;

axis1 value=('india' 'japan' 'usa' 'china' 'korea') ;

proc gchart data=have;

vbar country / discrete maxis=axis1;

run;

quit;

Thanks,

Jag

Thanks,
Jag
1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Instead of putting those values on the AXIS statement, put them on the MIDPOINTS option of the VBAR statement:

proc gchart data=have;

vbar country / discrete midpoints=('india' 'japan' 'usa' 'china' 'korea');

run;

quit;

Hope this helps!

Dan

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

Instead of putting those values on the AXIS statement, put them on the MIDPOINTS option of the VBAR statement:

proc gchart data=have;

vbar country / discrete midpoints=('india' 'japan' 'usa' 'china' 'korea');

run;

quit;

Hope this helps!

Dan

Jagadishkatam
Amethyst | Level 16

Thank you Dan for your response and it helped me.

In continuation to the above discussion, i would like to check with you , how we could create blank vbar for subgroup and group if the subgroup and group records are missing. To explain further, consider that we have category and sub-category as below

data have;

input subcat$ cat$;

cards;

A india

A india

A india

A india

B japan

B japan

C usa

A china

A china

A china

;

run;

proc gchart data=have;

vbar subcat  / discrete group=cat  subgroup=subcat ;

run;

quit;

Capture.JPG

This generates a graph as above, however if would like to create a blank vbar for korea with same subgroups. For this , should i need to create dummy records for korea in the data

or is there anything similar to midpoints. Please suggest.

Thanks,

Jag

Thanks,
Jag
DanH_sas
SAS Super FREQ

I think this will work for you:

axis1 order=("china" "india" "japan" "korea" "usa");

proc gchart data=have;

vbar subcat  / discrete group=cat  subgroup=subcat gaxis=axis1;

run;

quit;

Jagadishkatam
Amethyst | Level 16

Thank you Dan it helped

Thanks,
Jag

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
  • 2087 views
  • 1 like
  • 2 in conversation