Date: Fri, 11 May 2012 11:22:40 -0400
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: Need helps for creating table columns from a string
If the goal is to create an empty dataset with the charaters
in the string to be the variable names:
%let a=ACBD;
%let b=%sysfunc(tranwrd(%sysfunc(tranwrd(%sysfunc(tranwrd(&a,A,%str
(A ))),B,%str(B ))),C,%str(C )));
data x;
retain &b .;
stop;
run;
NOTE: The data set WORK.X has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
On Fri, 11 May 2012 11:16:58 -0400, Ya Huang <ya.huang@AMYLIN.COM> wrote:
>When the possible charater in the string is known and limited,
>you can do it brute force way:
>
>2 %let a=ACBD;
>3 %put %sysfunc(tranwrd(%sysfunc(tranwrd(%sysfunc(tranwrd(&a,A,%str
>(A ))),B,%str(B ))),C,%str(C )));
>A C B D
>
>It's an ugly one-liner, but copy/paste is not a big deal for any
>editor now :-)
>
>On Fri, 11 May 2012 10:27:07 +0100, Yu Chang
><Chang.Y@CAMBRIDGEASSESSMENT.ORG.UK> wrote:
>
>>Hi all.
>>
>>I have the following string:
>>
>>%let sting=ABCDEFG;
>>
>>How to create a table like this:
>>(The table columns are come from the specified string)
>>________________
>>A |B |C |D |E |F |G |
>>________________
>>
>>
>>Thanks for your help.
>>
>>Yu Chang
>>
>>
>>
>>
>>If you are not the intended recipient, employee or agent responsible for
>delivering the message to the intended recipient, you are hereby notified
>that any dissemination or copying of this communication and its
>attachments is strictly prohibited.
>>If you have received this communication and its attachments in error,
>please return the original message and attachments to the sender using the
>reply facility on e-mail.
>>Internet communications are not secure and therefore Cambridge Assessment
>(the brand name for the University of Cambridge Local Examinations
>Syndicate, the constituent elements of which are CIE, ESOL and OCR [Oxford
>Cambridge and RSA Examinations is a Company Limited by Guarantee
>Registered in England. Registered office: 1 Hills Road, Cambridge CB1
>2EU. Company number: 3484466]) does not accept legal responsibility for
>the contents of this message.
>>Any views or opinions presented are solely those of the author and do not
>necessarily represent those of Cambridge Assessment unless otherwise
>specifically stated.
>>The information contained in this email may be subject to public
>disclosure under the Freedom of Information Act 2000. Unless the
>information is legally exempt from disclosure, the confidentiality of this
>email and your reply cannot be guaranteed.
|