BookmarkSubscribeRSS Feed
early_stage
Calcite | Level 5

 

 

  

Hello,

 

I am trying to figure out the frequency of respondents who selected each answer choice. Using SAS 9.4. There were 10 answer choices to my question. This question is a "select all you can apply" question. However, when I run my code, I get very small percentages. Here's my code:

If find (Why_did_not_get_HPV_vaccine, "1") then Q185_1=1; else Q185_1=0;
If find (Why_did_not_get_HPV_vaccine, "2") then Q185_2=1; else Q185_2=0;
If find (Why_did_not_get_HPV_vaccine, "3") then Q185_3=1; else Q185_3=0;
If find (Why_did_not_get_HPV_vaccine, "4") then Q185_4=1; else Q185_4=0;
If find (Why_did_not_get_HPV_vaccine, "5") then Q185_5=1; else Q185_5=0;
If find (Why_did_not_get_HPV_vaccine, "6") then Q185_6=1; else Q185_6=0;
If find (Why_did_not_get_HPV_vaccine, "7") then Q185_7=1; else Q185_7=0;
If find (Why_did_not_get_HPV_vaccine, "8") then Q185_8=1; else Q185_8=0;
If find (Why_did_not_get_HPV_vaccine, "9") then Q185_9=1; else Q185_9=0;
If find (Why_did_not_get_HPV_vaccine, "10") then Q185_10=1; else Q185_10=0;
run;

 

Here are a portion of my results (the rest got cutoff in screenshot). As you can see, each answer has an extremely small percentage, which doesn't make sense. How would you recommend I change my coding so that I capture everyone who selected each answer choice?

Screen Shot 2023-02-27 at 11.15.38 AM 2.png

2 REPLIES 2
ballardw
Super User

This looks like it very likely a follow up to a question like "Did you get HPV vaccine?" In many surveys that means that the follow up question for "why not" would only be asked of those that said "No" to the "did you get" question. So would Your question response would be missing for any who said yes. If most of your respondents did get the vaccine and there is such a skip pattern then most of the responses you have created are from MISSING responses to the Why_did_not_get_HPV_vaccine question.

 

I might suggest, not having your data or full description of your survey that you try this if the skip pattern is in the survey:

if not missing (Why_did_not_get_HPV_vaccine) then do;
   If find (Why_did_not_get_HPV_vaccine, "1") then Q185_1=1; else Q185_1=0;
   If find (Why_did_not_get_HPV_vaccine, "2") then Q185_2=1; else Q185_2=0;
   If find (Why_did_not_get_HPV_vaccine, "3") then Q185_3=1; else Q185_3=0;
   If find (Why_did_not_get_HPV_vaccine, "4") then Q185_4=1; else Q185_4=0;
   If find (Why_did_not_get_HPV_vaccine, "5") then Q185_5=1; else Q185_5=0;
   If find (Why_did_not_get_HPV_vaccine, "6") then Q185_6=1; else Q185_6=0;
   If find (Why_did_not_get_HPV_vaccine, "7") then Q185_7=1; else Q185_7=0;
   If find (Why_did_not_get_HPV_vaccine, "8") then Q185_8=1; else Q185_8=0;
   If find (Why_did_not_get_HPV_vaccine, "9") then Q185_9=1; else Q185_9=0;
   If find (Why_did_not_get_HPV_vaccine, "10") then Q185_10=1; else Q185_10=0;
end;

The interpretation of your original code would "% of all respondents why not getting HPV".

The above suggestion would be interpreted as "of those that did not get HPV vaccination, reasons why".

 

Note: instead of writing a bunch of IF then as above you can use

Q185_10=(find (Why_did_not_get_HPV_vaccine, "10") );

the ( ) around the find question will evaluate the expression inside as a logical and return 1 for true (find > 0) or 0 (find was 0) for false.

 

Tom
Super User Tom
Super User

Nice answer, until the last sentence:

the ( ) around the find question will evaluate the expression inside as a logical and return 1 for true (find > 0) or 0 (find was 0) for false.

The parentheses are just grouping, so (2) is just 2 not True or False.

 

Perhaps you meant to include the 0< in the original expression. That will make a boolean result (with or without the extra parentheses).  PS Use FINDW() instead of FIND() and avoid false positives caused by finding '1' in '10'.

Q185_10=( 0 < findw(Why_did_not_get_HPV_vaccine, "10") );

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 435 views
  • 0 likes
  • 3 in conversation