Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sorting string variables- a couple of questions

    Dear Statalist,
    I've just ran a small pilot study, which is a 2*2 factorial survey conducted via the Qualtrics survey software. I have four conditions where my key dependent variables are 1) willingness to donate (Q33, Q47, Q42, Q56), 2) provide email address for opportunities for volunteering (Q34, Q48, Q43, Q57), 3) provide email address for subscription (Q35, Q49, Q44, Q58), and 4) provide phone number for further notifications about the organization (Q36, Q50, Q45, Q59). The problem that I am facing mainly comes from the fact that I have embedded identical questions within each condition (or question block), and therefore, I have to combine these open-ended answers into one variable. I did this using the following..

    Code:
    gen donate= Q33 + Q47 + Q42 + Q56 
    gen mail_vol = Q34 + Q48 + Q43 + Q57
    gen mail_news = Q35 + Q49 + Q44 + Q58
    gen phone = Q36 + Q50 + Q45 + Q59
    Now, I have something that looks like...
    Click image for larger version

Name:	20220311_141003.png
Views:	1
Size:	17.0 KB
ID:	1653945


    My questions while cleaning the data are...
    1) How can I replace values that do not have (for instance) a "@" to missings? This is for sorting those that are not proper email addresses.
    2) How can I replace values that are not in numeric (for the phone variable) to missings?

    Apologies for the screenshot and not using the dataex.. I've tried but failed due to long characters, probably email addresses.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str17 ResponseId str3 Q33 str36(Q34 Q35) str15 Q36 str3 Q47 str22(Q48 Q49 Q50) str3 Q42 str23(Q43 Q44) str10 Q45 str3 Q56 str26(Q57 Q58) str12 Q59
    data width (256 chars) exceeds max linesize. Try specifying fewer variables
    r(1000);
    Thanks for reading.
Working...
X