Date: Tue, 22 May 2007 16:34:07 -0700
Reply-To: Jeremy Miles <jeremy.miles@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jeremy Miles <jeremy.miles@GMAIL.COM>
Subject: Re: Autorecode strings to numeric
In-Reply-To: <941871A13165C2418EC144ACB212BDB0078DE8@dshsmxoly1504g.dshs.wa.lcl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 22/05/07, Nordlund, Dan (DSHS/RDA) <NordlDJ@dshs.wa.gov> wrote:
[snip]
>
> I guess I misunderstood what you wanted to do. It would definitely help to see a sample of the data that you want to convert. However, from your log it looks like string takes on values like
>
> Active PH Client
> Administrative Discharge
>
That's right, there are quite a few of these, and some of them are quite long.
> So, is your task to give these string values an abitrary numeric code? This could be
>done using a format or a variety of other techniques. For example,
something like
>
Yes. I'm new to SAS, having used SPSS before. The autorecode command
(in SPSS) puts the values into alphabetical order, and creates a new
variable, where the first becomes 1, the second becomes 2, etc.
> Proc format;
> value $strfmt
> 'Active PH Client' = 1
> 'Administrative Discharge' = 2
> other = 3
> ;
> Run;
> data temp1; set temp2;
> num = input(put(string, $strfmt.), best.);
> run;
>
>
> Write back to SAS-L with details of what your string looks like and what your recoded
> values should be, and maybe the higher goal that you are trying to achieve. That way
> someone may be able to give you better advice.
>
I wanted to write some code to place these into groups, so 1, 2, 3, 6,
7 and 9 (for e.g.) would become 1, and 8, 13, 14, etc, would become 2.
I could then write
if code = 1 or code = 2 or ... then censored = 1;
Without having to write each string out in full (and risk making mistakes).
Jeremy
> Hope this is helpful,
>
Yes, thanks,
Jeremy
--
Jeremy Miles
Learning statistics blog: www.jeremymiles.co.uk/learningstats
Psychology Research Methods Wiki: www.researchmethodsinpsychology.com
|