SPSS macro to flip ordinal variable labels so they graph well in Excel

SPSS macroEven though I do nearly all my analysis in SPSS, I still prefer to use Excel to graph my data.  Unfortunately Excel inverts the legend when graphing. Creating a new variable, or re-coding the old one, is time consuming and errors can creep in. This SPSS macro to invert an ordinal variable with very little work.  Saves an amazing amount of time!

It also has a built-in way to filter out too small a sample size.

 

 */////////////////////.   
DEFINE !ISubgp  (Var !TOKENS (1) /Cut !TOKENS (1) )
AUTORECODE   VARIABLES=!Var  /INTO SubGroup   /DESCENDING   /BLANK=MISSING   /PRINT.
AGGREGATE /OUTFILE=* MODE=ADDVARIABLES OVERWRITEVARS=YES /BREAK=subgroup  /Sub_CT=N .
Select if Sub_CT >=!Cut.
if missing(Subgroup) Sub_CT=$Sysmis.
Freq SubGroup.
exe.
!ENDDEFINE.
*/////////////////////. 
!ISubgp Var=Var_toInvert   Cut=20 . 

SPSS macro

The below video demonstrates the usage of the SPSS macro.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.