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 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 13 Mar 2010 16:02:05 -0500
Reply-To:     Nathaniel Wooding <nathaniel.wooding@DOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nathaniel Wooding <nathaniel.wooding@DOM.COM>
Subject:      Re: How to create a new grouped variable
In-Reply-To:  <201003132036.o2DBlMxV013449@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Dave

I don't use where statements so some of the syntax but your code would be a lot cleaner if you created a new variable

Cap_specimen = Upcase( specimen );

This assumes that you want to keep the mixed case value.

Then, your code does not need all those upcase statements and your program saves doing the same operation so many times. The actual cpu time may not change much but it still cuts down on what you have to read when looking over the code and eliminates a chance for error if you forget to do the upcase in every statement like I would.

Nat Wooding

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Dave Sent: Saturday, March 13, 2010 3:37 PM To: SAS-L@LISTSERV.UGA.EDU Subject: How to create a new grouped variable

Hi All,

Let me give you a little background of my problem.

I am processing results from different lab tests and the name of each lab test is not unique, which therein lies my problem.

The first thing I need to do is keep only the specimens (topography) and lab tests of interest. I do this with WHERE processing and the LIKE statement.

For example, a lab test name for "glucose" can vary from "glucose", "GLUCOSE", "1HR SERUM GLUCOSE", "2 Hr. GTT GLUCOSE", etc. All of the abouve tests need to be collapsed to a new variable "MAPPED_NAME" with a value "GLUCOSE". I need to do this type of collapsing for 20 different lab test NAMES.

My code thus far:

DATA LABS ;

retain rx RX1; if _n_ = 1 then rx = prxparse('/BLAST|CYTIC|CYTE|CELL|OPHIL|BAND|PLACENT|ENDOMETR |EMBRYO|SEMINAL|SEMEN|SPUTUM|VOMIT|URINE|FECES|FECAL|PARIETAL|OCCULT|YELLOW |PURPLE|ORANGE|GREEN|RED|TOP|BLUE /i');

if _n_ = 1 then rx1 = prxparse('/GLUCOSE /i');

SET SAVEIT.LABS_DB(DROP=MAPPED_NAME) ; WHERE ( ( UPCASE(SPECIMEN) LIKE '%BLOOD%' ) OR

( UPCASE(SPECIMEN) LIKE '%PLA%' ) OR

( UPCASE(SPECIMEN) LIKE '%SER%' ) OR

( UPCASE(SPECIMEN) LIKE '%ARTER%' ) OR

( UPCASE(SPECIMEN) LIKE '%VENO%' ) OR

( UPCASE(SPECIMEN) LIKE '%BLD%' ) )

AND

( ( UPCASE(NAME) LIKE '%BUN%' ) OR

( UPCASE(NAME) LIKE '%GLUCOSE%' ) OR

( UPCASE(NAME) LIKE '%UREA NITROGEN%' ) OR

( UPCASE(NAME) LIKE '%CREATININE%' ) OR

( UPCASE(NAME) LIKE '%SODIUM%' ) OR

( UPCASE(NAME) LIKE '%CHOLESTEROL%' ) OR

( UPCASE(NAME) LIKE '%ALBUMIN%' ) OR

( UPCASE(NAME) LIKE '%BILIRUBIN%' ) OR

( UPCASE(NAME) LIKE '%SGOT%' ) OR

( UPCASE(NAME) LIKE '%CPK%' ) OR

( UPCASE(NAME) LIKE '%WBC%' ) OR

( UPCASE(NAME) LIKE '%HCT%' ) OR

( UPCASE(NAME) LIKE '%PLT%' ) OR

( UPCASE(NAME) LIKE '%PTT%' ) OR

( UPCASE(NAME) LIKE '%FIO2%' ) OR

( UPCASE(NAME) LIKE '%PCO2%' ) OR

( UPCASE(NAME) LIKE '%PO2%' ) OR

( UPCASE(NAME) LIKE '%CO2%' ) OR

( UPCASE(NAME) LIKE '%TROPONIN%' ) OR ( UPCASE(NAME) LIKE 'PH %' ) OR ( UPCASE(NAME) LIKE 'PH(%' ) OR ( UPCASE(NAME) LIKE 'PH*%' ) OR ( UPCASE(NAME) LIKE 'PH,%' ) OR ( UPCASE(NAME) LIKE 'PH-%' ) OR ( UPCASE(NAME) LIKE 'PH@%' ) OR ( UPCASE(NAME) LIKE 'PH1%' ) OR ( UPCASE(NAME) LIKE 'PH2%' ) OR ( UPCASE(NAME) LIKE 'POC PH%' ) OR ( UPCASE(NAME) LIKE 'PH.%' ) OR ( UPCASE(NAME) LIKE 'ZPH%' ) ) ;

matchloc = prxmatch( rx, specimen ); if matchloc > 0 then flag = 1;

matchloc2 = prxmatch( rx1, NAME ); if matchloc2 > 0 then MAPPED_NAME = "GLUCOSE"; ; RUN;

Do I need to create a prxmatch for each lab test as I did for creating the MAPPED_NAME for GLUCOSE? As you can see, the biggest problem is identifying the correct "PH" string to keep.

Any thoughts or suggestions would be greatly appreciated.

Thanks for your time. Dave CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.


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