Date: Sat, 31 Oct 2009 07:46:39 -0400
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: Building a Character String
In-Reply-To: <200910311018.n9UGMWXx031771@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
David
Try the following code:
Data start;
input custid;
cards;
100
200
300
400
500
run;
Data string;
length string $200.;
set start end = eof;
retain string;
drop custid;
if _n_ = 1 then String = 'where custid in (';
if eof = 0 then
String = compbl( string || put(custid , 8. ) || ',' );
else do;
string = compbl( string || put(custid , 8. ) || ');') ;
output;
end;
run;
There are compress functions in V9 that are an improvement on those of V8.
Nat Wooding
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of David Friedman
Sent: Saturday, October 31, 2009 6:19 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Building a Character String
Hi, I have the following sample data:
custid
100
200
300
400
500
.
.
etc.
I want to build the following string:
where custid in (100, 200, 300, 400, 500.....)
I have SAS 8.21 installed at my location. What is the best way to accomplish
this? Thanks.
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.
|