From: sas analysis on
This is yet a simple question which I am not knowing how to do in sas:

I have a longitudinal dataset and I need to get how many unique
observations there are for each variable.

For example, if i have 5430 subjects and 80,000 observations. how do I
get unique observations for each variable based on the 5430 (how many
of the total 5430 said yes to smoking or no, even though smoking was
measured more than 20 times?)

any help would be great.
From: Tom Abernathy on
On Mar 20, 5:18 pm, sas analysis <sasanaly...(a)gmail.com> wrote:
> This is yet a simple question which I am not knowing how to do in sas:
>
> I have a longitudinal dataset and I need to get how many unique
> observations there are for each variable.
>
> For example, if i have 5430 subjects and 80,000 observations. how do I
> get unique observations for each variable based on the 5430 (how many
> of the total 5430 said yes to smoking or no, even though smoking was
> measured more than 20 times?)
>
> any help would be great.

If you have coded your variables as numeric then use PROC MEANS/
SUMMARY to get the MAX (or MIN depending on your coding) per subject.



proc summary data=in ;
class id;
var smoke ;
output out=out max= ;
run;

proc means data=out ;
run;
From: Reeza on
On Mar 20, 2:18 pm, sas analysis <sasanaly...(a)gmail.com> wrote:
> This is yet a simple question which I am not knowing how to do in sas:
>
> I have a longitudinal dataset and I need to get how many unique
> observations there are for each variable.
>
> For example, if i have 5430 subjects and 80,000 observations. how do I
> get unique observations for each variable based on the 5430 (how many
> of the total 5430 said yes to smoking or no, even though smoking was
> measured more than 20 times?)
>
> any help would be great.

There's also a proc freq, for each subject by answer to smoking.
I'd definitely save it to a data set rather than print it out though;

Something like this:
***NOT TESTED****

proc freq data=in noprint;
tables subject*smoking/out=test;
run;