Help using Base SAS procedures

Help Please

Reply
N/A
Posts: 0

Help Please

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..
Regular Contributor
Posts: 165

Re: Help Please

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.
N/A
Posts: 0

Re: Help Please

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??
Respected Advisor
Posts: 3,887

Re: Help Please

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
Frequent Contributor
Posts: 75

Re: Help Please

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
Ask a Question
Discussion stats
  • 4 replies
  • 144 views
  • 0 likes
  • 4 in conversation