| Date: | Wed, 20 Feb 2008 10:37:15 -0500 |
| Reply-To: | "data _null_," <datanull@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "data _null_," <datanull@GMAIL.COM> |
| Subject: | Re: SAS Coding Question |
|
| In-Reply-To: | <2ac439730802200702mdd8d55bu89b94dde58cf0c77@mail.gmail.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
S needs to be trimmed.
Q1_4text = tranwrd(Q1_4text,trim(s),';');
I'm not sure this is the best approach, can you explain the overall
goal. This looks like a check all that apply with OTHER category that
you are trying to capture.
On Wed, Feb 20, 2008 at 10:02 AM, Xuhong Zhu <zhuxuhong2000@gmail.com> wrote:
> Hello Data _null_,
> Thanks for your help. However,I found some strange results after I
> tried your solution on my dataset
> . I output 10 observations here. Hope you could help me take a look!
> Always, thanks very much!
>
> data Websur_2;
> length Q1_4text $50;
> set Websur_1 (keep= Q1_4);
>
> Q1_4text=Q1_4;
> length s $30;
> do s = 'ARNP','DO','MD','MS', 'PhD', 'RN', 'Other (Please Specify)';
> Q1_4text = tranwrd(Q1_4text,s,';');
> end;
> Q1_4text=left(compress(Q1_4text,';'));
> drop s;
> run;
>
> proc print data=websur_2 (obs=10);
> run;
>
> /******* partial output ******/
> Obs Q1_4text
>
> 1 MD
> 2
> 3
> 4
> 5
> 6 MD
> 7
> 8
> 9 MDOther (Please Specify)MBA
> 10
>
> Obs Q1_4
>
> 1 MD;MS
> 2 MD
> 3 MD
> 4 MD
> 5 DO
> 6 MD;MS
> 7 MD
> 8 MD
> 9 MD;Other (Please Specify);MBA
> 10 MD
>
>
>
>
> On Feb 19, 2008 4:51 PM, data _null_, <datanull@gmail.com> wrote:
> > Assuming the removal of A; B; or C; leaves the desired text.
> >
> > data work.test;
> > input line $50.;
> > newLine=line;
> > do s = 'A;','B;','C;';
> > newline = tranwrd(newline,s,' ');
> > end;
> > newline=left(compress(newline,';'));
> > drop s;
> > cards4;
> > A;B;C;south asian;
> > C;Indian;
> > A;C;B;
> > ;;;;
> > run;
> > proc print;
> > run;
> >
> > On Feb 19, 2008 4:41 PM, Xuhong <zhuxuhong2000@gmail.com> wrote:
> > > Hello folks,
> > >
> > > I need your help with my coding scheme.
> > >
> > > I have a variable falling into the following pattern:
> > >
> > > A;B;C;south asian;
> > > C;Indian;
> > > A;C;B;
> > > ...
> > >
> > > What I want is to find a method to create a new variable which will
> > > contains
> > > the text fields which are not the 'A' and 'B' and 'C'.
> > >
> > > Thanks a lot!
> > >
> >
>
|