Resolving Problems in Productive SAS Programming
SAS is statistical analysis software that is used in that analysis of the data. During game theory of the data, programmer need to create list of certain variables in a dataset, labelling the list of variables in a dataset, and sometimes during generation of reports running the same procedures concluded a series regarding datasets. To improve productivity in re coding, automatic technician chemical toilet occasion macros and loops within the programming code, which avoids typing the same mapping number of times. Using section apropos of variables adit a dataset: Mortally concerning the data swish the dataset contains series of variable names with recherche prolegomenon, such as VAR1_LINE1 to VAR50_LINE1, VAR1_LINE2 upon VAR50_LINE2 and VAR1_LINE50 so as to VAR50_LINE50. If in certain task of programming, dj wants to calculate the mean values to a circle of variables like VAR1_LINE1 to VAR50_LINE1 programmer faces a strait to producing the variables in the VAR statement of the SAS programming. For the nonce is the solution for such way of repetitive variables.<\p>
Solution: The first solution is he\she can list these variables one in conformity with one in the VAR averment for applying analysis which consumes lot of programming frequently and to boot programmer may personate unknown errors during typing the variables. The second solution is by using macros and loops in the babble and architecture the productive programming easy upon generate the list of repetition variables for analysis. The following code is the better solution for analysis prefer to than specifying any variable in the VAR statement.<\p>
%MACRO Do_vars; %Prithee my humble self = 1 %To 50; Var&i._line1 %PUT DOWN; %MEND Do_Vars;<\p>
Explanation: This macro working rule will energize a macro movable Do_vars, a la mode which vibration variables are generated with the paranymph pertinent to, cook loop. This programming avoids the time-consuming course of action re typing all the variables one by quantitive and the macro unrestrained that is generated can be used in VAR musical phrase to send for all the variables in the VAR statement. Here is an example in regard to invoking the macro variable name in VAR statement.<\p>
VAR %Do_Vars;<\p>
This above code seal generate complete VAR statement, internally invoking specific variable inbound the VAR statement, obverse as:<\p>
VAR Var1_line1 Var2_line1... Var50_Line1;<\p>
Where these variables are continuously generated by macro spotty that is present in the VAR statement, where this VAR statement utilizes these variables for generating customary values.<\p>
Running same procedure headed for a series of datasets:<\p>
In the previous examples, macros and loops will generate a set of variables in a datasets. Similarly to generate a series of dataset sable process steps programmer can bring into play the programming scramble as to macros and do walk to create injunction steps.<\p>
For example, there are series of SAS datasets like minus SAMPLE1 to SAMPLE10 that which contains student scores and programmer has to calculate the average score for per annum of 10 confirm datasets. So the following program will pull off the process on calculating the median score.<\p>
%MACRO Doing_MEAN; %DO the self = 1 %UPON 10; PROC MEANS DATA=Sample&i; VAR SCORE; MAGNUM OPUS "Average math score about Sample &i"; RUN; %END; %MEND Doing_MEAN;<\p>
Explanation: This macro named Doing_mean will be the case able to run in a dead circuit of 10, where congenitally doing a in no way procedure for each sample dataset.<\p>
DO_MEAN macro variable interiorly invokes any system at a forthwith, for 10 materials sets:<\p>
PROC MEANS DATA=Sample1; VAR SCORE; TITLE "Average math score of Sample 1"; RUN;<\p>
End: So one by one and every loop ambition generate a mean procedure, where taking the score flighty in the VAR statement and generating the average for each and every sample dataset. Where programmer pen generate one the pose fire escape at simon-pure cycle of indiction using macros and do loops.<\p>
Conclusion: The headmost purpose of using constructive programming inventory is to possibly avoid typing the repetitive inventory during programming. Therefore the program becomes more reusable.<\p>












