LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 22 Mar 2001 09:32:41 -0800
Reply-To:   Dale McLerran <dmclerra@MY-DEJA.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Dale McLerran <dmclerra@MY-DEJA.COM>
Subject:   Re: variable TYPE
Comments:   To: daniela.andren@economics.gu.se
Content-Type:   text/plain

Daniela,

Do you want to restructure the files which are already in place? Establishing consistency for variable types can pay off in the long run, but it can also break existing programs, so may not be worth it. One way around this problem is to create views of the data which alter the variable type at the time that the data are read. This is probably the approach which I would recommend. Here is an example of retyping a variable with a view. In this example, we assume that gender has a character representation, with values "0" and "1". We want to convert it to numeric 0 and 1.

data mydata_v / view=mydata_v; set mydata(rename=(gender=gender_)) gender=input(gender_,1.); drop gender_; run;

Now, instead of concatenating mydata, you concatenate mydata_v. The variable gender has its type assignment changed during the concatenation operation because a view does not contain any data. Instead, a view is an instruction on how to read the data. I believe that this may be just the trick you are looking for.

Dale

>Date: Thu, 22 Mar 2001 11:46:04 +0100 >Reply-To: Daniela =?iso-8859-1?Q?Andr=E9n?= <Daniela.Andren@ECONOMICS.GU.SE> >From: Daniela =?iso-8859-1?Q?Andr=E9n?= <Daniela.Andren@ECONOMICS.GU.SE> >Subject: variable TYPE >To: SAS-L@LISTSERV.UGA.EDU > >Hi! > >I need to concatenate 25 files that contain the same variables, BUT they >have different TYPE (sometimes they are CHARACTER, sometimes they are >NUMERIC) and/or names. > >It seems that when the variables changed the names, they also changed the >type. If I REANME the variables, when I merge the files I got the message >that the same variable is both numerical and character… > >Any suggestion to change the type of variables before merging the files (or >any other solution) is very much appreciated. > >Regards, >Daniela

--------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

------------------------------------------------------------ --== Sent via Deja.com ==-- http://www.deja.com/


Back to: Top of message | Previous page | Main SAS-L page