FAQ/bar - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Type the missing letters from: He's no ded, he's jus resing hs eys

Revision 11 as of 2012-05-03 15:18:27

location: FAQ / bar

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.