This question needs a little more clarity in order to answer. What are you trying to accomplish? Some PROCs permit a certain amount of programming statements, such as PROC REPORT or PROC GLM.
Is the issue that you want to be able to reference the observation count from a SAS data step within a SAS Procedure? Sometimes, the answer is not to look for new programming, but ask how your data is organized. Many times, instead of doing a case by case analysis, you could have a CLASS variable or a BY variable if you want the procedure executed for each value of a certain variable.