## Demystifying the Ternary Operator in AutoHotkey: Short-hand If-Else logic

AutoHotkey has pretty straight-forward If-Then-Else logic however it can take quite a few lines of code to do some simple evaluations.   Ternary Operators are a great way to write short / concise code in one line!  🙂

The basic form is that you first evaluate a condition.  If the value resolves to being true, the first parameter is returned.  If it is False, the second parameter is returned.

(Condition)?(True) : (False)

## Drastically reduce work needed for Factor Analysis with SPSS Macro

SPSS Macros drastically reduce the time needed to run factor analysis and creating summary variables.  In the video below I demonstrate how you can greatly increase the speed at which you analyze your data as well as creating the new variables with summary factor scores.

By running Factor analysis twice (but changing the output) you can make it much easier to create summary variables once you’re happy with your solution!

## Video demonstrating SPSS Macro running Factor Analysis

Here is the SPSS macro for Factor analysis:

```
*///////////////.
DEFINE !Factor (Rotate !TOKENS (1)   / Title !Tokens (1)  / Sav  !Tokens (1)  /Varys !CMDEND)
Include "B:\SPSS\Syntax\Output_Off.SPS".
script "B:\SPSS\Scripts\Empty.sbs".

Include "B:\SPSS\Syntax\Show Names.SPS".
FACTOR  /VARIABLES !Varys  /PRINT ROTATION  /FORMAT SORT  /CRITERIA MINEIGEN(1) ITERATE(25)  /EXTRACTION PC
/CRITERIA ITERATE(50)   /METHOD=CORRELATION /ROTATION !Rotate  / !Unquote(!SAV).
Script "B:\Scripts\Parse\Clean viewer.sbs" ("Component Transformation Matrix").
Script "B:\Scripts\Parse\Clean viewer.sbs" ("Component Matrix").
script "B:\Scripts\S2\Wrap Rows.sbs".
*Script "B:\Scripts\Factor Flag.SBS".
Script "B:\Scripts\Flag above .45.SBS".
Script "B:\Scripts\Flag above .65.SBS".
Script  "B:\Scripts\Flag above .80.SBS".
Script "B:\Scripts\S2\Right Align Column.SBS".
Script "B:\Scripts\Parse\Clean viewer.sbs" ("Total Variance Explained").

*/ Second run of SPSS Macro *.
Include "B:\Syntax\Show Labels.SPS".
FACTOR  /VARIABLES !Varys  /PRINT ROTATION  /FORMAT SORT  /CRITERIA MINEIGEN(1) ITERATE(25)  /EXTRACTION PC
/CRITERIA ITERATE(50)   /METHOD=CORRELATION  /ROTATION !Rotate.
Script "B:\Scripts\Parse\Clean viewer.sbs" ("Component Transformation Matrix").
Script "B:\Scripts\Parse\Clean viewer.sbs" ("Component Matrix").
script "B:\Scripts\S2\Wrap Rows.sbs".
*Script "B:\Scripts\Factor Flag.SBS".
Script "B:\Scripts\Flag above .45.SBS".
Script "B:\Scripts\Flag above .65.SBS".
Script  "B:\Scripts\Flag above .80.SBS".
Script "B:\Scripts\S2\Right Align Column.SBS".
!ENDDEFINE.
*///////////////.
!Factor  Rotate=Varimax   SAV="SAVE REG(ALL)"      Varys=  to  .*/
/*EQUAMAX     QUARTIMAX  VARIMAX  */.```

And here is the other SPSS macro which eases creating of a new factor.  It takes a little getting used to but is well worth the effort if you’re doing a lot of factor analysis.

```*////////////////.
DEFINE !CreateFac  (NewFac !TOKENS (1) / Label !TOKENS (1)  / Vars=!CMDEND)
Compute !NewFac=Mean(!HEAD(!Vars) !DO !v !IN (!TAIL(!Vars)) , !v !DOEND ).
Format !NewFac (F5.2).
Var Label !NewFac !Label.
exe.
!ENDDEFINE.
*////////////////.
/*!CreateFac  NewFac=Joe Label="Joe Rocks" Vars=Enc_friend Proud Und_wrk_res Eth_Std Job_aligns MissPurp.
```

Learning Macros | Raynald’s SPSS Tools

This page is a simple introduction to macros. There are several fully (line- by-line) commented examples . Overview of several macro-related …

Programming with SPSS Syntax and Macros – Tarstud.hu

Instead, a SPSS macro could generate the SPSS Syntax for each interactive graph within a loop, substituting a new rating scale variable name per iteration.

## GIS Data

Years ago I helped a company that worked in the financial industry review where their current locations are and where FDIC Banks were located.  The GIS data was available for free from the FDIC.  If you spend some time you can merged the files together and look at it longitudinally.   The below map was particularly helpful in deciding where a new branch/office should be located.  I also imported the locations of competitors however I cannot share this data as it is too revealing.

I used Microsoft’s MapPoint to create the below map.  It is no longer with us however this would be easy to repeat with Google Maps.

Here’s a great book to get ideas on conveying data visually

## API for Sales Prospecting

I have a lot of friends that work in sales and spend an awful lot of time (manually) trying to find new sales leads.  There are a lot of sources out there (LinkedIn, Hoovers, InfoUSA, etc. ) which allow you to use a web browser for searching through their database.  Others open up access to their data by way of an webservice API.

The Clearbit prospect API allows you to find people and bring back demographics as well as email address.  The video demonstrates two examples where I of the Propector and Autocomplete Clearbit APIs.