BookmarkSubscribeRSS Feed
rfisher
Calcite | Level 5

Hey Guys, 

 

I'm new to SAS and currently trying to examine correlations between answers to survey questions where participants were asked to position themselves on a seven-point-scale. In this survey, there were also values above 7 reserved for things like "dont know" or "dont care" which obviously I want to exclude from the correlation analysis. 

 

But: If im not mistaken, SAS Studio doesn't led me include multiple where-clauses into a correlation analysis. I already tried to put them directly into the code but then the log showed that only the last one hat been included into the calculation. Does anybody have a solution?

 

Thanks and best regards, Robert 

2 REPLIES 2
ballardw
Super User

If this were "where clauses" related you should show what you have been attempting, what the clauses look like.

 

However, typically with survey data in the situation you describe it is very common to create recoded variables where the "don't know" "refused" or "not applicable" type of answers are set to missing so they are excluded from analysis of the scales.

 

In code terms if you have many similar response ranges to set you can use an array:

Array q   q1 q2 q5;  /* the q1 q2 q5 represent the names of the variables you want to recode you may be able to reference as q1-q10 if the ones you want have numeric suffixs and are in order*/

Array r   rq1 rq2 rq5; /* these variables will hold the results of the recodes should look exactly like the ones in Q but with a change to the names, you will discover that prefixing is preferred to suffixing  as lists like q1r - q10r do not behave as desired*/

/* the next line assumes your scale runs 1 to 7 and the values to remove are greater than 7. Any comparison that works is okay, such

as if q[i] in ( 10, 12, 0) then r[i]=.;

do i = 1 to dim(q);

   if q[i] > 7 then r[i]=.;

   else r[i] = q[i];

end;

 

I recommend adding a label to your recoded variables.

 

For some purposes you could use a custom format to indicate special missing that would indicate the original reason the data is set to missing but the special missing may be included in some places (proc freq output for example) when you may not want them.

Astounding
PROC Star

To me, one of the most important ideas is included in ballardw's response but not explained enough.  Consider this variation on the array processing:

 

array q [3]  q1 q2 q5;

do i = 1 to 3;

   if q[i] =8 then then q[i]=.A;

   else if q[i]=9 then q[i] = .B;

   else if q[i]=10 then q[i]=.C

end;

 

The idea is that you can afford to permanently change your existing data ... IF you can still distinguish among the answers greater than 7 and identify what they were originally.  Special missing values let you do that.  Once you have saved special missing values instead of the original values, procedures will automatically treat those values differently than they would nonmissing values.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 646 views
  • 0 likes
  • 3 in conversation