Diff for "FAQ/bar" - CBU statistics Wiki
location: Diff for "FAQ/bar"
Differences between revisions 11 and 12
Revision 11 as of 2012-05-03 15:18:27
Size: 2277
Editor: PeterWatson
Comment:
Revision 12 as of 2013-03-08 10:17:15
Size: 2277
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Empty categories in a SPSS bar graph

A bar graph for groups (in variable group) may be produced in SPSS using the syntax below

WEIGHT BY freq.
GRAPH
  /BAR(SIMPLE)=COUNT BY group.

If a rating scale has a category which doesn’t occur, e.g. ‘Impaired’, this category is not shown in bar charts. This can be a disadvantage, for example, in checking for Normality or even getting an impression of the complete range of possible data values. This can be overcome by weighting the cases.

Example Let’s suppose we wish to graph group frequencies, for abilities on a particular task on a simple bar chart. Nobody is classed as 'impaired'. We, therefore, add a second variable, wdat, containing the frequencies and a small positive value, for example 0.001, for the non-occurring impaired group. This group will now be represented in the bar chart. The bar chart may be edited in the output window by clicking on particular portions.

[THE SPSS SYNTAX IN THE BOX BELOW CAN BE PASTED INTO A SPSS SYNTAX WINDOW AND RUN; THE DATA MAY BE AMENDED AS REQUIRED]

* in the below the groups are defined by fdat with total 
* frequencies (summed over individuals) wdat. If raw (individual)
* data is entered  wdat takes value ‘1’ for each observed data 
* point and ‘0.001’ for any data points which could have occurred * but did not.

Data list free/
Fdat wdat.
Begin data
1 0.001
2 2
3 10
4 5
end data.

VAR LABELS      FDAT     ABILITY/
                WDAT     WEIGHT /.  

VALUE LABELS   FDAT (1) IMPAIRED
                    (2) BELOW AVERAGE
                    (3) AVERAGE
                    (4) ABOVE AVERAGE.

DEFINE !MYBAR          (!POS !TOKENS(1)
                      / !POS !TOKENS(1)   
                      / !POS !CMDEND).
WEIGHT BY !2 .
GRAPH TITLE=!QUOTE(!3)
  /BAR(SIMPLE)=COUNT BY !1
  /MISSING=REPORT.
!ENDDEFINE.

!MYBAR FDAT WDAT DISTRIBUTION OF ABILITY GROUPS. 

* Multiple invocations of the macro in the same interactive session will produce the following note:

>The macro name specified on the DEFINE command duplicates the name of a previously defined macro. This instance will take precedence.

This warning does not indicate a problem and may be ignored.

None: FAQ/bar (last edited 2014-03-28 10:24:44 by PeterWatson)