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 (June 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 19 Jun 2006 21:58:45 -0700
Reply-To:     Jagadish <jagadishkr@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jagadish <jagadishkr@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Working on String mathematical expressions
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset="iso-8859-1"

Hi All, I have a dataset which has a character variable called var1. Below are the sample records of this dataset.

Var1 1+2+3 3+4+5 10+20+100

I want to create a new numeric variable say Var2 which is the result the string expressions. The final dataset should look like,

Var1 Var2 1+2+3 6 (3+4)*5 35 (30-20)+100 110

I tried with the below code and it is working fine, data x; length var1 $100; input var1 & $; call symput('x', var1); call execute('%let x=%Eval(&x);'); var2=symget('x'); cards; 1+ 2 + 3 (3 + 4 ) * 5 (30 - 20) + 100 ; run;

I just wanted to know is there any better way to do this. I mean without usinng macro variables or is there any SAS function to handle string math expressions?

Thanks, Jagadish


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