Hi,
I want to display all empty datasets in my Gchart. How do I do that?
I am just learning SAS.
I thank you all in advance.
Best,
Ali
Your request doesn't make sense, if there is no data then there is no graph? Or do you want to display axis and thats it? If so then you would need a conditional block to check if there are observations in your data and if not then use a default dataset with one observation, and set the color of the point or line it creates to the background color - i.e. create a graph with data, but set the color so it doesn't display. However it really makes no sense to produce graphics if there is no data. If we have this scenario, then replace the whole graph production with just the text stating that there is no data.
Thank you for replying to my query.
I do have a dataset and I know how to create graphs with that. I want to dispaly all participants' names in HBAR y-axis. I want this after a particular date, say october 1, 2016. But after that only 3 of our 10 participants contributed and its showing only those 3 participants, not all. I want display all participants in the graph even if they have not contributed after that date.
Here is my code which I am using,
PROC GCHART DATA=a5; where survey_complete_dt>'01oct2016'd;;
hBAR prov_name/discrete subgroup=other_studies;
RUN;
Thanks,
Ali
Well, first tip - move to sgplot (graph template language). It is so much more powerful and easy to use. I wouldn't use anything else but that now (since 9.X). In that you can set the values to appear on the axis, so, (and I don;t have any of your data or what you want, so guessing here), if I want to show PT=1, 2, 3, 4 on the yaxis even if they don't exist (noting that 1,2,3,4 would be formatted per your requirements) I would stipulate:
proc sgplot data=have; yaxis values=(1 2 3 4); vbar ...; run;
If you need further examples, here is an excellent blog which will give you code:
http://blogs.sas.com/content/graphicallyspeaking/
With almost any procedure when you subset the data with a where statement you will need to ensure that your desired respondents will match the where clause to have a chance of appearing the graph. This may mean that you have to add dummy records that just have the respondent and date but not actual response values, or if you are displaying sum values then you may need to have 0.
Often the solution may involve summarizing the data before the graph procedure to ensure that you have the values the procedure wants to use for display. I presummarize almost everthing except scatter or series plots.
As ballardw says, you might need to insert some 'zero' values into your data.
Here's a small example to demonstrate that. The first one uses a 'missing' value (which doesn't show up in the bar chart), and the second example uses a value of zero (which does show up in the graph)...
data foo;
length name $6;
name='Fred'; value=.; output;
name='Robert'; value=4; output;
name='Tim'; value=2; output;
run;
proc gchart data=foo;
hbar name / type=sum sumvar=value;
run;
data foo;
length name $6;
name='Fred'; value=0; output;
name='Robert'; value=4; output;
name='Tim'; value=2; output;
run;
proc gchart data=foo;
hbar name / type=sum sumvar=value;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.