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 (December 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 28 Dec 2009 20:29:32 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Fw: extracting numbers from a string
Comments: To: William Krause <wkrause2003@YAHOO.COM>
Content-Type: text/plain; charset=ISO-8859-1

Bill,

The specific suggestions, and degree of complexity, will be a function of what your data files "really" look like.

I took a shortcut, in the event that responses in tab2 actually might be separated by a distinguishable character (like a comma).

If they are, something as simple as the following might suffice:

data tab1; informat question $10.; informat infmt $5.; informat response $50.; input question infmt response; cards; question1 1. 1="test1",2="test2",3="test3" question2 2. 1="test1",2="test2",3="test3",11="test11",13="test13" question3 2. 1="test1",2="test2",3="test3",11="test11",13="test13" ;

data tab2; informat question $10.; informat resp_results $50.; input question resp_results; cards; question1 1 question2 13 question3 5 ;

proc sort data=tab1; by question; run;

proc sort data=tab2; by question; run;

data want; merge tab1 tab2 (in=b); by question; if b; resp=inputn(resp_results,infmt); valid="false"; do i=1 to 5; if resp eq inputn(scan(scan(response,i,","),1,"="),infmt) then valid="true"; end; run;

HTH, Art ------- On Mon, 28 Dec 2009 14:08:21 -0800, William Krause <wkrause2003@YAHOO.COM> wrote:

>--- On Mon, 12/28/09, William Krause <wkrause2003@YAHOO.COM> wrote: > > >From: William Krause <wkrause2003@YAHOO.COM> >Subject: extracting numbers from a string >To: SAS-L@LISTSERV.UGA.EDU >Cc: "William Krause" <wkrause2003@YAHOO.COM> >Date: Monday, December 28, 2009, 1:45 PM > > >I have a metadata table (tab1)that contains a field(infmt) which is the >informat of a another field(response).� The response field contains the >response number and its assigned description. > >tab1 >question���infmt response >question1� 1.� � 1="test1"2="test2"3="test3" >question2� 2.� � 1="test1"2="test2"3="test3"11="test11"13="test13" >question3� 2.� � 1="test1"2="test2"3="test3"11="test11"13="test13" > >Then I have a second table (tab2) which contains the actual response values >in a field (resp_results) > >tab2 >question���resp_results >question1���1 >question2���13 >question3���5 > >How do I insure that the resp_results in tab2 matches the informat of the >infmt field and matches a valid response number from the response field in >tab1? > >Thanks for you assistance. > >Bill K. >wkrause2003@yahoo.com >


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