SPSS Statistics

SPSS Statistics

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


#Analytics
#SPSSStatistics
#Analyticstools
 View Only
Expand all | Collapse all

Return Binary if String Var contains Specific Text

  • 1.  Return Binary if String Var contains Specific Text

    Posted 08/07/20 05:13 PM

    I have a comma separated list that I would like to parse with a 0 or 1 if the text is present.

    For example, my list looks like this:

    1. apache, namecheap_dns, wordpress
    2. google_apps, dns_made_easy, ubuntu, google_adsense, wordpress, nginx
    3. apache, wordpress
    4. apache, google_maps
    5. apache, google_maps, google_analytics, google_tag_manager
    6. microsoft_exchange_online, sendgrid, outlook, microsoft_office_365, google_analytics, youtube, twitter_button, talend, oracle_peoplesoft, sage_50cloud, quickbooks, webmethods, sap_hana, oracle_data_integrator, informatica, db2, apache_tomcat, alteryx, ...
    7. apache, apache_http_server, github, godaddy_nameserver, google_analytics, google_maps, hotjar, microsoft_power_bi, mysql, recaptcha, sap_crm, tawk

    I would like to create a new variable called "Apache" and have a 0 for records that do not have apache in the list and 1 where it is present.

    I have tried the following command, but it only returns 0's, and I'm not sure why.

    COMPUTE NewVar_Apache = (CHAR.INDEX(UPCASE(CurrentTechVar),'apache') > 0).

    EXECUTE.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 2.  RE: Return Binary if String Var contains Specific Text

    Posted 08/07/20 05:14 PM

    FYI, by comma-separate list, I mean a single variable has a comma separated list as its values.






    #SPSSStatistics
    #Support
    #SupportMigration