Difference between 2 N's

Difference between 2 N's

Post by Alex Pavl » Sat, 01 Oct 2005 23:08:35


Hello. I have a dataset where I want to display the number of
observations for 2 different variables and the difference between them.
Right now I am using the following code but I am not sure about how to
get the difference. Thanks in advance.


proc means data=combined N;
var DUBPARTS PARTICIPANTS;
label DUBPARTS='Count of Person_ID from original dataset'
PARTICIPANTS='Count of unique Person_ID';
title 'Breakdown of participants';
run;
 
 
 

Difference between 2 N's

Post by Toby » Sat, 01 Oct 2005 23:25:49

Alex ,

S *** the proc means approach and go with SQL.

proc sql ;
select count(DubParts) as DubPartsN ,
count(Participants) as ParticipantsN ,
abs(calculated DubPartsN - Calculated ParticipantsN) as Diff
from <whatever> ;
quit ;

Toby Dunn


Hello. I have a dataset where I want to display the number of
observations for 2 different variables and the difference between them.

Right now I am using the following code but I am not sure about how to

get the difference. Thanks in advance.


proc means data=combined N;
var DUBPARTS PARTICIPANTS;
label DUBPARTS='Count of Person_ID from original dataset'
PARTICIPANTS='Count of unique Person_ID';
title 'Breakdown of participants';
run;

 
 
 

Difference between 2 N's

Post by awz » Sun, 02 Oct 2005 02:05:19

I guess Toby's asking to figure out the number of unique id, those
duplicated or null should not be counted.

Your SQL will give the total number of records in the table if the
condition clause "where" is not specified. So the diff will always be
0.

There is no simple solution to the problem because we need to count the
unique unduplicated or null variables. And these variables are
unlikely to be indexed.
SQL has an option to count the dupicated records, but I don't remember
now..

AWZ
 
 
 

Difference between 2 N's

Post by Toby » Sun, 02 Oct 2005 03:39:08

AWZ,

Send a sample file and the rules for when each variable shoudl get
summed and when you want the difference calculated.

Toby Dunn
 
 
 

Difference between 2 N's

Post by awz » Sun, 02 Oct 2005 11:15:25

Toby,

There's typo. It is Alex's question.

I construed a simple data set like this:

field1 field2
100 200
101 201
102 201
---------------------
each time I have count(field1) = count(field2) = 3, diff=0
Will you figure out a way to exclude the duplicated value?
e.g count(fiedl2) = 2 if not count the 201 twice.

AWZ
 
 
 

Difference between 2 N's

Post by tobydun » Sun, 02 Oct 2005 13:42:08

awz,

To exclude the duplicates try:

Proc sql ;
select Count(feild1) as Field1Cnt ,
Count(distinct Filed2) as Field2Cnt
from somedata ;
quit ;


Toby Dunn





From: awz < XXXX@XXXXX.COM >
Reply-To: awz < XXXX@XXXXX.COM >
To: XXXX@XXXXX.COM
Subject: Re: Difference between 2 N's
Date: Fri, 30 Sep 2005 19:15:25 -0700
MIME-Version: 1.0
Toby,

There's typo. It is Alex's question.

I construed a simple data set like this:

field1 field2
100 200
101 201
102 201
---------------------
each time I have count(field1) = count(field2) = 3, diff=0
Will you figure out a way to exclude the duplicated value?
e.g count(fiedl2) = 2 if not count the 201 twice.

AWZ