09-21-2012 09:00 AM
I have a dataset with 3 columns:
1. Student id
In the date column, I have values in mmddyy10 from jan11-dec12. The Marks column contains values of marks for each day for the period jan11-dec12.
I want to calculate a new variable called percentagedifference_30days that should have corresponding values from jan 31st.
Formula: percentagedifference_30days= (jan31st mark - jan1st mark/jan 1st mark)
So start from Jan 31st, I want Percentagedifference_30days calculated for each day and for each student_id. The result value shoud roll for the whole year.
The idea of this excercise is to determine the growth or decrease of each student for the whole year. So can anybody provide me the base SAS code plz?
09-21-2012 09:11 AM
It would be most useful to other folks who might be inclined to help you if you provided:
1) a copy of your code or the code you've tried
2) some data to try -- for example when you have "marks" as the 3rd variable, I thought it might be 1 number, but then you said "contains values of marks for each day" So I can't envision your data because it is not clear whether you have this:
Alan 01/01/2011 98 <--- one mark
Alan 01/01/2011 98 95 98 <--- multiple marks for the same day
3) some idea of what this is needed for (you need a report showing the percent difference, you need an output data set that contains the new variable)
4) an idea of further processing or handing. For example -- if you need an output dataset -- what other analysis do you need to perform? if you need a report -- what type of report -- HTML, RTF, PDF?
09-21-2012 10:15 AM
Well, if I understand you correctly, you are trying to mark improvement percent base on 30 days interval. Here is one approach you could meddle around to suit your need:
do id=1 to 10;
do date=1 to 365;
array t(0:30) _temporary_;
do _n_=1 by 1 until (last.id);
if _n_>=31 then pct=(t(mod(_n_,31))-t(mod((_n_-30),31)))/t(mod((_n_-30),31));