Hey everyone,
Im new at SAS so i apologize for asking what i assume is a pretty basic function. I have a few million observations and i cant just edit my csv file so i need to manipulate the data in SAS. Im looking to use a function to make a calculation based on any changes in the data in the first two columns.
I would be grateful if someone can tell me if this is possible or do i have to use the proc sql command. Perhaps a screenshot and my coding will help explain better.
http://img148.imageshack.us/img148/6771/49349620.jpg
Based on the example in the screenshot above, i'm calculating R=log(P/lag(P)).
If you look at the screenshot, R is what i want to achieve, while "Wrong R" is what i get from using the code below.
data example1;
set example2;
by variable date;
r=log(P/lag(P));
run;
The conditions to get R is that every time theres changes in the column Variable and Date, I want the data in R for that field to reset to NA as i cant utilize the pre-existing data point in column P.
I hope that explains it well enough, appreciate any help i can get, thanks in advance!