Date: Tue, 28 Oct 2008 10:50:19 -0700
Reply-To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Organization: http://groups.google.com
Subject: Re: how to assign a same variable into two different new
variables in SAS
Content-Type: text/plain; charset=ISO-8859-1
On Oct 27, 5:21 am, les_daniel <leonhardye...@gmail.com> wrote:
> Hi,
> is it possible to re-assign a same variable into two different
> two variables, as a result of a revision/regruping of codes in the
> stocklist as shown using proc format...
>
> proc format;
> value $stock
> '34211'='34312'
> '34211'='34124''
> '31412','33213'='23412'
> '23456'='56789'
> ;
>
> i got an error in the 1st two lines cos it seems like it can't read
> in the same old code twice assigned in this manner,while the 3rd line
> is ok...so it there any possible way to accept the same(old) varable
> ('34211'), grouped into two new grouping as shown for
> classification...?
>
> '34211'='34312','34124'; /* can be work also? */
You can use the MULTILABEL feature to have a single input value map to
more than one output value. Not all procedures deal with multi-label
formats (MLF), however, TABULATE is one that does.
This numeric example should kickstart your thinking regarding your
character format scenario.
--------------
proc format;
value xmulti (MultiLabel)
1,3,5,7,9,11,13,15,17,19 = 'Odd'
2,4,6,8,10,12,14,16,18,20 = 'Even'
1-5 = '1 to 5'
6-10 = '6 to 10'
7-15 = '7 to 15'
15-20 = '>14'
1-10 = 'Lower 1/2'
10-20 = 'Upper Half'
;
run;
data foo;
do x = 1 to 20;
output;
end;
format x xmulti.;
run;
ods html
file="%sysfunc(pathname(WORK))\table.html"
style=journal
;
proc tabulate data=foo order=data;
class x / MLF;
table x,n;
run;
ods html close;
--------------
Richard A. DeVenezia
http://www.devenezia.com
|