Date: Thu, 18 Jul 1996 17:06:24 GMT
Reply-To: Frank Schnekenburger <ay987@FreeNet.Carleton.CA>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Frank Schnekenburger <ay987@FREENET.CARLETON.CA>
Organization: The National Capital FreeNet
Subject: Re: help!!!
Wei Jin (jin.fpg@mhs.unc.edu) writes:
> I met a problem about converting one variable to the other. Say,
> I have variable A which has possible value "1,2,3...." and I would
> like to creat variable B which has possible value "9,13,27,...". there
> seems no mathematic connection between the two group of value except
> if A=1 then B=9, if A=2 then B=13 etc. I have 100 value in each group.
> Is there any "elegant" way to do the convertion other than 100 if-then
> clause?
Hello, Assuming that A is sequential and inclusive (1, 2, 3 ... n),
the following code should do the trick (no if statements required).
Frank.
* create sample file of variable A;
data old;
input a @@;
cards;
4 2 3 1 3 5 1 4 2 4 3
;
* create a lookup table for conversion, specifying values of B in the
order corresponding to the 1, 2, 3... of A;
data lookup;
input b @@;
cards;
9 13 27 37 49
;
* convert A to B;
data new;
set old;
set lookup point=a;
run;
|