LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 1999, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 11 Oct 1999 17:17:55 -0400
Reply-To:   Royce_Claytor@VAPOWER.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Royce Claytor <Royce_Claytor@VAPOWER.COM>
Subject:   Re: create new variable
Comments:   To: yzhao@HAAS.BERKELEY.EDU
Content-type:   text/plain; charset=us-ascii

You could use the function Scan.

Your data is as follows: vari

AAA H-D LIQ -.25 AAA H-D LIQ BBBBB H-D LIQ CCCC H-D LIQ PP DD H-D LIQ

The following code works; however, the 4th variable is a character variable. Its value can be -.25 or PP. By specifying only the delimiter of blank, the default delimiter of hyphen is not used.

Data one(drop=vari); Input vari $ 1-30; Var1 = Scan(vari,1,' '); Var2 = Scan(vari,2,' '); Var3 = Scan(vari,3,' '); Var4 = Scan(vari,4,' ');

Hope this helps, Royce (804) 775-5552

yzhao@HAAS.BERKELEY.EDU on 10/11/99 04:13:53 PM

Please respond to yzhao@HAAS.BERKELEY.EDU

To: SAS-L@LISTSERV.UGA.EDU cc: (bcc: Royce Claytor/IT/VANCPOWER) Subject: create new variable

Hi SAS Experts,

I was trying to create new variables from my old variables. The old variable looks like the following:

var1

AAA H-D LIQ -.25 AAA H-D LIQ BBBBB H-D LIQ CCCC H-D LIQ PP DD H-D LIQ

The value under the variable name var1 has 30 number of bytes, some of them is space. I would like to seperate the value of "var1" into several varibles which will be in the format:

var1 var2 var3 var4 AAA H-D LIQ -0.25

because the would-be-first variable's number of bytes is not fixed (AAA, BBBBB, CCCd, DD...), I found it is difficult for me to do this. Do you have any hints of how to do this?

Thank you very much!

YingZhao

Sent via Deja.com http://www.deja.com/ Before you buy.


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