SPSS Statistics

 View Only
  • 1.  String data with an apostrophe

    Posted Wed April 17, 2024 06:03 PM

    I am working with an SPSS data set with string data. I noticed that one of the string values in the data set is "I probably wouldn't do that" – note the apostrophe. In my syntax, the cell with a value of "I probably wouldn't do this" is part of a conditional statement, as in…

    Else if (I6l_0='I would never do this') or (I6l_0='I probably wouldn't do this').

    However, because the conditional string statement has an apostrophe, SPSS is interpreting that as the end of the string statement, so the syntax is not correct.

    I thought about editing the data file so that everywhere it says "I probably wouldn't do this", I could take out the apostrophe, then include the de-apostrophed conditional statement in my syntax. My efforts to find an easy way to take out all of the apostrophes from the data file have thus far failed – I'd like to do a "Find" and "Replace" like in a word processing program, but "Find" in the SPSS menu does not seem to work that way (or I am using it incorrectly). Is anyone aware of an easy way to de-apostrophe the data set? 

    Other ideas I had were to Sort the Cases by the values of the pertinent variables and edit them on a case-by-case basis… or recode the string value to a numeric one…. Or read the file into something like Excel and do a Find and Replace…. but was wondering if there was an easy way to do the job within SPSS. 

    So -- is anyone aware of an easy way to de-apostrophe the data set? 

    Thanks - Janet



    ------------------------------
    Jaycee
    ------------------------------


  • 2.  RE: String data with an apostrophe
    Best Answer

    IBM Champion
    Posted Wed April 17, 2024 06:36 PM
    From the Command Syntax Reference

    Each string specified in a command should be enclosed in single or double quotes.
    • To specify a single quote or apostrophe within a quoted string, either enclose the entire string in double
    quotes or double the single quote/apostrophe. Both of the following specifications are valid:
    'Client''s Satisfaction'
    "Client's Satisfaction"
    • To specify double quotes within a string, use single quotes to enclose the string:
    'Categories Labeled "UNSTANDARD" in the Report'

    --





  • 3.  RE: String data with an apostrophe

    Posted 30 days ago

    See here: https://www.ibm.com/docs/en/file-manager-for-zos/14.1?topic=interface-specifying-quoted-strings



    ------------------------------
    Marianne Pelletier
    ------------------------------



  • 4.  RE: String data with an apostrophe

    Posted 30 days ago
    Thank you, Marianne!





  • 5.  RE: String data with an apostrophe

    IBM Champion
    Posted 30 days ago
    That link has nothing to do with SPSS, but it is consistent with the SPSS behavior as I posted from the SPSS Command Syntax Reference.

    --





  • 6.  RE: String data with an apostrophe

    Posted 30 days ago

    Thanks -- I noticed it referred to file names but basically said the same thing you had. :-)



    ------------------------------
    Jaycee
    ------------------------------