|
|
Dear Bia,
There may be a neater method (like a Python extension but I'm not sure) but the classical solution is to add one case and weight it to almost zero. This also works for frequency tables. For an example, see below. HTH, Ruben van den Berg Consultant Models & Methods TNS NIPO Email: [hidden email] Mobiel: +31 6 24641435 Telefoon: +31 20 522 5738 Internet: www.tns-nipo.com *Generate test data. input program. loop id=1 to 100. compute v1=rnd(rv.uni(.5,3.5)). end case. end loop. end file. end input program. execute. variable label v1 'favorite pet'. add value labels v1 0 'cat'1'dog'2'turtle'3'other'. dataset name d1. graph /bar=v1. *No cat in the graph. Assuming you have no weighting variable, all your normal cases should count as one case. compute weight=1. *Now we create a single phantom case who prefers a cat and we give her a virtually zero weight. data list free/v1 weight. begin data 0 1e-15 end data. *Now we add this case to the original data. add files file * /file=d1. execute. *Now we activate the weighting variable. weight by weight. *And now cat is included with zero frequency. graph /bar=v1. Date: Mon, 7 Jun 2010 02:32:00 -0700 From: [hidden email] Subject: How can a have a graph show categories with 0 frequency? To: [hidden email]
Express yourself instantly with MSN Messenger! MSN Messenger |
|
In reply to this post by bia-2
HI Bia You can do this easily in chart builder. Just make sure your
ordinal variable is defined as Ordinal (i.e. on the Variable View tab of the
Data Editor, set the Measure for that variable to Ordinal). Then make sure you
have entered value labels for every value of the ordinal variable you want to
display in your chart. That’s it. You can then produce a histogram or a bar chart which
will show all values of the ordinal variable even ones with zero frequency. Garry Gelade Business Analytic Ltd From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Bia
|
|
In reply to this post by Ruben Geert van den Berg
You can specify the categories to appear in the chart explicitly using GPL. Paste your bar chart syntax from the Chart Builder, and you will see a SCALE statement similar to the following SCALE: cat(dim(1), include("1", "2", "3")) You can add other categories as needed to the include portion of the statement. HTH, Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
Dear Bia, There may be a neater method (like a Python extension but I'm not sure) but the classical solution is to add one case and weight it to almost zero. This also works for frequency tables. For an example, see below. HTH, Ruben van den Berg Consultant Models & Methods TNS NIPO Email: [hidden email] Mobiel: +31 6 24641435 Telefoon: +31 20 522 5738 Internet: www.tns-nipo.com *Generate test data. input program. loop id=1 to 100. compute v1=rnd(rv.uni(.5,3.5)). end case. end loop. end file. end input program. execute. variable label v1 'favorite pet'. add value labels v1 0 'cat'1'dog'2'turtle'3'other'. dataset name d1. graph /bar=v1. *No cat in the graph. Assuming you have no weighting variable, all your normal cases should count as one case. compute weight=1. *Now we create a single phantom case who prefers a cat and we give her a virtually zero weight. data list free/v1 weight. begin data 0 1e-15 end data. *Now we add this case to the original data. add files file * /file=d1. execute. *Now we activate the weighting variable. weight by weight. *And now cat is included with zero frequency. graph /bar=v1. Date: Mon, 7 Jun 2010 02:32:00 -0700 From: [hidden email] Subject: How can a have a graph show categories with 0 frequency? To: [hidden email]
Express yourself instantly with MSN Messenger! MSN Messenger |
| Free forum by Nabble | Edit this page |
