| Date: | Tue, 6 Dec 2011 13:05:04 -0500 |
| Reply-To: | "Viel, Kevin" <kviel@SJHA.ORG> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Viel, Kevin" <kviel@SJHA.ORG> |
| Subject: | Re: capturing some visits |
| In-Reply-To: | <CABOqZswGrU4DhFPAyOWkGEMOm75exPtCjDOU5T1F+kLvjq7rmQ@mail.gmail.com> |
| Content-Type: | text/plain; charset="us-ascii" |
While Toby's solution suffices, I like "extendible" approaches, too:
Data _null_ ;
Length Y $ 8 ;
Do x = 1 to 2.1 by 0.01 ;
If Mod( X , 1 ) ne 0 Then Y = Put( X , 8.2 ) ;
Else Y = Put( X , 8.0 ) ;
If PRXMatch( "/^1\.?.*$/" , Strip( Y )) Then Put Y= ;
Else Put "*" Y "*" ;
End ;
Run ;
The carrot ("^") says that the match must start at the beginning of the string while the dollar sign says that they match must also end at the end of the string. The "\." Is a match of the literal period ("."), but it must be escaped using the backslash ("\"). The next period "." matches any byte (character). I could have used \d for the digits 0-9, but this is flexible. However, I allow zero any number of matches by using the asterisk ("*").
This can be extended to the first ten visits only:
"/^\d+(\.0.)*$/"
i.e. x-x.09, but it may be overkill:
0 <= mod( Input( X , 8. ) , 1 ) <= 0.09
One always has several ways to do it...
HTH,
Kevin
Kevin Viel, PhD
Senior Research Statistician
Patient Safety & Quality
International College of Robotic Surgery
Saint Joseph's Translational Research Institute
Saint Joseph's Hospital
5671 Peachtree Dunwoody Road, NE, Suite 330
Atlanta, GA 30342
(678) 843-6076: Direct Phone
(678) 843-6153: Facsimile
(404) 558-1364: Mobile
kviel@sjha.org
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of sas
> quest
> Sent: Tuesday, December 06, 2011 11:57 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: capturing some visits
>
> hi all,
> i have a dataset with visits
> 1,1.01,1.02,2,2.02,2.03,3,3.01,3.02,3.03,3.04....until 15 or so.
> If i need to capture say all visits that start with 1,or 3 how do i code
> it
> efficiently?
>
> I tried the colon operator but didnt work because it will include
> 10,11,...
> if visit in: (1,3);
>
> i can do this with index/find but dont want to keep guessing visits.
>
> Thanks
Confidentiality Notice:
This e-mail, including any attachments is the
property of Catholic Health East and is intended
for the sole use of the intended recipient(s).
It may contain information that is privileged and
confidential. Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are
not the intended recipient, please delete this message, and
reply to the sender regarding the error in a separate email.
|