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 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 24 Oct 2004 12:22:32 -0400
Reply-To:     "Zack, Matthew M." <MMZ1@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Zack, Matthew M." <MMZ1@CDC.GOV>
Subject:      FW: trying to use if then statements on variables
Content-Type: text/plain; charset="us-ascii"

Because you include in your calculations array values, CLOSE[i+4] and CLOSE[i+9], that exceed the supposed number of observations [=1,200] in your data set, your DATA step code won't work unless either you have 1,209 observations, or the index of your iterative DO-END loop does not exceed 1,191[=1,200-9].

Matthew Zack

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of T. Sent: Saturday, October 23, 2004 12:53 PM To: SAS-L@LISTSERV.UGA.EDU Subject: trying to use if then statements on variables

Hello, I am a new user and have a dataset with "close" as the only initial variable. It is a closing stock price. I have tried this with arrays and now am trying it with IML. What I want to do is just get my data set up so I can perform the simple if then process in the second block of code. The other variables are in my dataset but have zero values. They are "avg" (avg daily return over the course of a week), "gain" (profit made by selling a stock), "purchase" (the quantity purchased of a the stock). Ultimately I want to be able to compute the total "gain" over the dataset after after running this algorithm through all 1200 observations.

PROC IML; use out_dat; read all into mat[colname=name]; time=mat[,1]; gain=mat[,2]; avg=mat[,3]; purchase=mat[,4]; close=mat[,5]; out_mat = time || gain || avg || purchase || close; cname = {"_time_" "_gain_" "_avg_" "_purchase_" "_close_" }; create Aout_dat from out_mat [ colname=cname ]; append from out_mat; run;

data Aout2_dat; set Aout_dat; do i=1 to 1200; avg[i]=log(close[i+4])-log(close[i]); If avg[i]>0 then do; purchase[i]=(1000/close[i+4]); gain[i]=purchase[i]*close[i+9]; end; end;

drop i; run;


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