@dxiao2017 wrote:
Base on your answer, my version (for creating dataset with days) is like this (the proc sort and proc report steps and the results are the same). Although I used more steps and statements, I think the logic is easier to understand for new users, especially who is not good at math, do not remember many functions, and not get used to more advanced techniques such as array and nested loops.
I disagree that the logic you used is easier to understand than what @Tom showed. In my work, I see people all the time trying to do something the hard way, they put a huge amount of effort into it (like I assume you did) and they write a lot of code, when this isn't necessary, and there are much easier ways to get the desired output.
And so in this case, @Tom has shown how to get the output with a lot less code. He even gave good advice to people who have this or similar problems, he said "Easier if you make a TALL dataset instead." Also, Tom has not used arrays or nested loops, and he has shown very useful methods (like use TALL data sets and PROC REPORT) that SAS programmers ought to learn early in their career. SAS has done the hard work for you, so you don't have to work hard.
By the way, @dxiao2017 , maybe you were replying to the code from @quickbluefish, but your actual post says you are replying to @Tom .
... View more