DATA Step, Macro, Functions and more

day on day code run

Posts: 26

day on day code run


I have data where todays closing becomes next days opening after calculations in Base SAS Code I have written and I have data from Jan2016 to Jul2016 so what is happening here is when I run one time data for 1st jan matches when I run second time data for 2nd jan matches and so on but how to cut down this repeting process short so that I can get all the matching values in one go.



Super User
Posts: 6,936

Re: day on day code run

Please supply

- example data (data step)

- the code you already have

- the intended result

Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 1,374

Re: day on day code run

Please give a sample example of your data and the output you want.

Occasional Contributor
Posts: 12

Re: day on day code run

Please provide the dataset for further reference and to drill down on the question





Super User
Posts: 5,081

Re: day on day code run

We're all guessing, but this might be what you want:  compute today's opening.


If so, the opening for the first day can't be computed.  But here's one approach to get as much as possible from the data:


proc sort data=have;

by company date;



data want;

set have;

by company;

opening = lag(closing);

if then opening=.;


Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation