SPSS Statistics

 View Only
  • 1.  Help! Completely lost as to syntax commands!

    Posted 9 days ago

    Hello Everyone - I am struggling to compile my large dataset and am assuming syntax commands or vectors are the answer, although I am very new to both. My questions are specific to what syntax commands (or other methods) I should use to create hundreds/thousands of new variable names so I do not need to do it manually. Creating the variable names will allow me to input the nominal/numerical data easily. Explained below.

    I am working with a dataset involving intimate partner homicides and domestic violence services utilization among victims from 2012-2021 (10 years), involving monthly data (120 months total). Across that timeframe, I have a three variable set: 1. REC [number of clients who received services]; 2. CALL [number of calls for services]; and 3. HOUR [number of hours advocates/employees spent providing services]) that needs to be repeated monthly Jan-Dec across 10 years 2012-2021 and 39 separate services. See below:


    "Month" in the above is Jan-Dec (01-12), "Year" is 2012-2021 (12-21), and "ServiceName" would be replaced with 39 different services. As an example for the year 2017 and "Shelter" services:

    0317_HOUR_Shelter .....so on and so forth until December of 2017. So new variable names need created using syntax or whatever else works (???). I would then need to modify the syntax to create similar variable names for Group Counseling, Legal Advocacy, Economic Assistance, etc. (e.g., 0117_REC_GrpCouns; 0117_CALL_GrpCouns; 0117_HOUR_GrpCouns, so on and so forth until December).

    To further explain: This sequential monthly order would need to be repeated for each year AND each month in the 2012-2021 timeframe for each of 39 domestic violence services for which I have data (three variables per month - REC, CALL, HOUR across 10 years and 120 months x 39 services). 

    My overall question is (sorry for the repetition)- What syntax commands would I need to input that I could modify to create this MASSIVE amount of new variable names? I am completely lost as to methods. I hope this makes sense to everyone in the same way it makes sense in my head. Sorry for the length of the discussion and thank you in advance.

    With gratitude.
    Shannon Harper, Ph.D.

    Shannon Harper

  • 2.  RE: Help! Completely lost as to syntax commands!

    Posted 9 days ago
    I can't be sure, but I think you are going about this in the wrong way.  Why do you need to create all these different variables?  Usually with problems like this, if you need to work with subsets of the cases, say, year by year, you would just subset the data with a SELECT IF or FILTER command or use SPLIT FILES.

    If for some reason you do need to separate the data, you could split it into separate sav files using the SPSSINC SPLIT DATASET extension command and use SPSS PROCESS FILES to  apply an analysis to each.


  • 3.  RE: Help! Completely lost as to syntax commands!

    Posted 8 days ago
    something like the following will do what you are asking to do (you will need to retype it making sure there is at least one space before the !do, !doend and !concat and eliminating any 'strange' characters that the email might be introducing in the text).

    * start.
    define !doit().
    new file.
    input program.
    loop case = 1 to 10.
    end case.
    end loop.
    end file.
    end input program.

     !do !y = 2012 !to 2021
     !do !m = 1 !to 12
     !do !v !in("REC CALL HOUR")
     !do !s !in("GrCoun LeAdv EcoA Etc")


    * end.

    but, i agree with jon, for data entry and manipulation you might be better off having a long file with the variables year, month, service, type and value, and then you can transpose this data as needed for pairwise comparisons.

    Eugenio Gonzalez