BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Is there not a code block in EG?  I haven't used it in years, but you can create items and link them together, and one of those items is SAS code files.  Then within the SAS code file you write a datastep to process your data as you want.  And yes, retain is the method you want to use.

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214163.htm

gregor1
Quartz | Level 8

Thanks RW9 for your reply...I need to think about that and how to proceed.  I am not an experienced coder so will need to read up on you comments.  Have been trying to figure it out for a while, so your comments give me another lead.

Tom
Super User Tom
Super User

You are going to have a problem if the variable you want to create already exists. Either drop the empty BEGIN and END variables or create your new values using different variable names.  Let's make your test data into an actual dataset.

data have ;
  input date team $ group $ category $ incoming outgoing ;
  informat date yymmdd. ;
  format date yymmdd10. ;
  put (_all_)(+1);
cards;
2013-06-25  A  1  AUTO  1  0
2013-07-02  A  1  AUTO  1  0
2013-07-09  A  1  AUTO  0  1
2013-07-10  A  1  AUTO  2  0
2013-07-11  A  1  AUTO  2  0
2013-07-12  A  1  AUTO  0  2
;

Not sure what the other variables are for, so we can just ignore them fro now.  If they represent some type of grouping of the data then you will need to add some BY processing statements.

So basically you want to RETAIN the new END variable so that you can store the old value into BEGIN.  The SUM statement (variable + expression) will make that happen and also initialize it to zero.

data want ;
  set have ;
  begin = end ;
  end + incoming - outgoing;
run;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 17 replies
  • 4018 views
  • 2 likes
  • 5 in conversation