LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2012, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 15 Mar 2012 15:19:22 +0000
Reply-To:     "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Subject:      Re: COMPARE procedure: any way to get xtab freqs on var value
              differences?
In-Reply-To:  <587F57B26FAA8246A81D10D251EB8AB402A52C02EE@EXCH07.GHCMASTER.GHC.ORG>
Content-Type: text/plain; charset="us-ascii"

here is some code from the late 20th century:

http://www.sascommunity.org/wiki/Macro_ComparWS_Compare_with_summary

Yeah, 1997, this is one of my earliest attempts to harness the SAS robot and have it write code for me.

My 100 wpm cannot keep up with SAS.

Ron Fehd relatively-fast typist, not(half- ...)

> -----Original Message----- > From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] > On Behalf Of Pardee, Roy > Sent: Wednesday, March 14, 2012 7:19 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: COMPARE procedure: any way to get xtab freqs on var value > differences? > > Hey All, > > I think the answer here is 'no', but wanted to check w/you kind experts... ;-) > > Consider this code: > > data other_class ; > set sashelp.class ; > if sex = 'F' then age = 12 ; > run ; > > proc compare base = sashelp.class compare = other_class ; > id name ; > run ; > > The bit of output that shows the obs that are different looks like so: > > __________________________________________________________ > || Base Compare > Name || Age Age Diff. % Diff > ________ || _________ _________ _________ _________ > || > Alice || 13.0000 12.0000 -1.0000 -7.6923 > Barbara || 13.0000 12.0000 -1.0000 -7.6923 > Carol || 14.0000 12.0000 -2.0000 -14.2857 > Janet || 15.0000 12.0000 -3.0000 -20.0000 > Joyce || 11.0000 12.0000 1.0000 9.0909 > Judy || 14.0000 12.0000 -2.0000 -14.2857 > Mary || 15.0000 12.0000 -3.0000 -20.0000 > __________________________________________________________ > > > That's helpful, but what I'd *really* like is crosstab list of the different values- > -something like: > > Base Compare > Age Age N % > --------------------------------- > 13 12 2 28.6 > 14 12 2 28.6 > 11 12 1 14.3 > > > So--basically what you'd get if you had both vars on a single dset & said: > > proc freq order = freq ; > tables base_var * compare_var / list ; > run ; > > There's no way to get that out of COMPARE today, is there? > > Many thanks! > > -Roy > > P.S. Here's a macro I wrote to get the output I want, in case the above isn't > clear: > > %macro compare_var(varname) ; > proc sql ; > create table diffs as > select o.mrn, o.enr_start, o.enr_end, o.&varname as old_&varname., > n.&varname as new_&varname., (o.&varname = n.&varname.) as > &varname._match > from old as o INNER JOIN > new as n > on o.mrn = n.mrn AND > o.enr_start = n.enr_start AND > o.enr_end = n.enr_end > ; > quit ; > title "Agreement on variable &varname.." ; > proc freq data = diffs ; > tables &varname._match / missing format = comma12.0 ; > run ; > proc freq data = diffs order = freq ; > tables old_&varname * new_&varname / list missing format = comma12.0 ; > tables enr_end / missing ; > where not &varname._match ; > format enr_end year4. ; > run ; > title " " ; > > %mend compare_var ; > > > Roy Pardee | DATA WRANGLER > Group Health Research Institute > > PHONE 360-447-8773 | 206-287-2078 > E-MAIL pardee.r@ghc.org > www.grouphealthresearch.org > > GHC Confidentiality Statement > > This message and any attached files might contain confidential information > protected by federal and state law. The information is intended only for the > use of the individual(s) or entities originally named as addressees. The > improper disclosure of such information may be subject to civil or criminal > penalties. If this message reached you in error, please contact the sender > and destroy this message. Disclosing, copying, forwarding, or distributing the > information by unauthorized individuals or entities is strictly prohibited by > law.


Back to: Top of message | Previous page | Main SAS-L page