BookmarkSubscribeRSS Feed
deleted_user
Not applicable
So there is one respondent for every Survey.. However that person may respond up to 16 times and there are multiple surveys. I want to know how I can find out if someone has responded to multiple surveys..
4 REPLIES 4
RickM
Fluorite | Level 6
Hi,

How does the data look? Is it in one dataset or multiple? Without some more info it is really hard to suggest a solution.
deleted_user
Not applicable
The data is in a single set.

looks something like this

Respondent Address Survey Survey Number

Sue 55555 A 03


And it repeats.

Sue might be in 30 times for 1 survey but 60 times if she answered Survey B and C> i want to know how do I subset the data to find out how many times sue answered survey B and C without Counting the 60 times for Survey A??
Patrick
Opal | Level 21
Here a SQL approach:

data have;
infile datalines truncover;
input Respondent $ Address $ Survey $ Survey_Number ;
datalines;
Sue 55555 A 03
Sue 55555 A 04
Sue 55555 A 05
Sue 55555 A 06
Sue 55555 B 03
Sue 55555 B 04
Sue 55555 C 01
XXX 55555 C 01
;
run;

proc sql;
/* create table result1 as*/
select Respondent, Survey, count(*) as Times_Answered
from have
group by Survey,Respondent
;
quit;

proc sql;
/* create table result2 as*/
select Respondent, Survey, max(Survey_Number) as max_Survey_Number
from have
group by Survey,Respondent
;
quit;

There would also be a whole bunch of SAS Proc's you could use instead like:
Freq, Means, Tabulate, Report

HTH
Patrick Message was edited by: Patrick
dhana
Fluorite | Level 6
The below code will give you the expected result. Please check

PROC FREQ DATA=HAVE;
By Respondent;
TABLES Survey;
RUN;

Regards

Dhanasekaran R
AllianzCornhill Information Services
Trivadrum

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 713 views
  • 0 likes
  • 4 in conversation