SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Creating Category Variables based on a Date

    Posted Wed June 22, 2022 02:53 PM
    Hello,
    I am trying to create a category variable based on a customer's start date (formatted yyyy/mm/dd). I have set SPSS to have this date as a Date Variable and as a nominal number. My categories would be 1=First Year Customer (since 2021/03/01; 2=Standard; 3=Veteran Customer (before 2010/01/01). I have tried the following operations, without success, to create this variable:
    1) Recode to different Variables/If Statement
    2) Select Cases
    3) Compute Variable

    Is there something I am missing here? Feel free to offer any suggestions needed to create this new variable. 
    Thanks,
    Frank Ready
    fready@revgen.com

    ------------------------------
    Frank Ready
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Creating Category Variables based on a Date

    Posted Wed June 22, 2022 03:41 PM
    Date variables look like dates when displayed, but their values are actually large numbers.
    You can use the yrmoda(yy, mm. dd) in an IF or DO IF statement to set a value based on that date.
    Or, use the RECODEEX extension command (Transform > Extended Recode) extension command.  For example,
    SPSSINC RECODEEX
    bdate = dategroup
    /RECODES "LO THRU 1966-11-08 = 1"  "LO THRU 1970-01-01 = 2"
    /OPTIONS VALUELABELS=YES USEINPUTVALLABELS=NO COPYVARIABLELABELS=NO.
    etc.

    This works like the built-in RECODE command, although the sntax is slightly different, but it understands date constants in the format yyyy-mm-dd  (also time).

    You can install it from the Extensions > Extension Hub menu if you don't have it.  If  you have an old version of the command, reinstall it from the EH to get the current version.

    --