I have a dataset with 3 columns:
1. Student id
2. date
3. Marks
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?
Hi:
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
or
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?
cynthia
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:
data have;
do id=1 to 10;
do date=1 to 365;
mark=ceil(ranuni(0)*100);
output;
end;
end;
run;
data want;
array t(0:30) _temporary_;
do _n_=1 by 1 until (last.id);
set have;
by id;
t(mod(_n_,31))=mark;
if _n_>=31 then pct=(t(mod(_n_,31))-t(mod((_n_-30),31)))/t(mod((_n_-30),31));
output;
end;
run;
Haikuo
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: