02-07-2013 04:12 PM
Apologies if this is a very elementary question, but I've been scouring my SAS reference book as well as the online support pages/google for an answer and haven't found an easy way to do this yet...So:
While iterating over a dataset via a datastep, I want to be able to keep a counting variable and increase its value after each observation within the data step. I.e: I want to increase the numeric value of a column cell by 100 in the first observation, 200 in the second, 300 in the third, and so on...My thought was to just use a global macro initially set to 100, and add 100 to it via symput("var" (value + 100)); or via %let assignments, but the value of the variable remains constant throughout all obervations of the datastep in both of my attempts...Surely such an elementary capability can't be such a difficult process right? Am I just missing something simple here?
Please let me know if anyone has an idea.
Thanks a lot guys, I appreciate your time!
02-08-2013 05:07 AM
Hi, I am sorry I am aware that this has been answered but just in case you were not aware that the RETAIN keyword can be very useful for dealing with iterations. So, here your solution with RETAIN will be:
retain value 0;
Need further help from the community? Please ask a new question.