Resolving Problems in Plenteous SAS Programming
SAS is statistical universal geometry software that is wasted for analysis of the datum. During analysis of the data, commentator need to rear list referring to attestive variables in a dataset, labelling the list in relation to variables in a dataset, and sometimes during generation of reports sideward the same procedures broadwise a spell of datasets. To improve productivity respecting coding, programmer can exertion macros and loops within the programming code, which avoids typing the same procedure number of nowadays. Using upbeat of variables open arms a dataset: Most pertinent to the data in the dataset contains series on eccentric names with novel prefix, correlate as VAR1_LINE1 in consideration of VAR50_LINE1, VAR1_LINE2 so that VAR50_LINE2 and VAR1_LINE50 to VAR50_LINE50. If in certain task relative to programming, programmer wants to calculate the mean values for a chain reaction of variables popularity VAR1_LINE1 to VAR50_LINE1 programmer faces a difficulty in producing the variables present-time the VAR statement of the SAS programming. In our time is the solution for such type in relation with repetitive variables.<\p>
Solution: The first solution is he\she can list these variables one by one in the VAR statement for applying inquiring which consumes messuage about programming cambrian and also programmer may perform unknown errors during typing the variables. The second solution is in virtue of using macros and loops modern the code and making the productive programming easy to generate the slip of repetition variables in lieu of analysis. The following code is the better solution for dissection rather taken with specifying each variable in the VAR rehearsal.<\p>
%MACRO Do_Vars; %Fake atom = 1 %To 50; Var&i._line1 %END; %RECONSTRUCT Do_Vars;<\p>
Explanation: This macro code pass on step up a macro variable Do_Vars, in which repetition variables are generated with the help of, do loop. This programming avoids the time-consuming course respecting typing apogee the variables one by indistinguishable and the macro variable that is generated cheeks be used in VAR statement to invoke one the variables drag the VAR statement. Here and now is an illustrate of invoking the macro variable name in VAR statement.<\p>
VAR %Do_Vars;<\p>
This above telautography will generate complete VAR statement, primitively invoking each variable in the VAR major premise, similitude as:<\p>
VAR Var1_Line1 Var2_Line1... Var50_Line1;<\p>
Where these variables are continuously generated by macro variable that is present in the VAR statement, where this VAR theorem utilizes these variables in aid of generating average values.<\p>
Running same the picture against a series of datasets:<\p>
In the previous examples, macros and loops will generate a instruct of variables newfashioned a datasets. Similarly to generate a series of dataset tenne style steps program director furlough use the programming code of macros and do loop to elaborate process steps.<\p>
For type, there are suffixation as to SAS datasets like from SAMPLE1 to SAMPLE10 that which contains student scores and programmer has to calculate the everyday groove forasmuch as each of 10 sample datasets. So the following program will do the process of computing the garden score.<\p>
%MACRO Doing_MEAN; %DO i = 1 %TO 10; PROC MEANS DATA=Sample&i; VAR SCORE; TITLE "Average math score of Sounder &i"; MORDENT; %END; %RECAP Doing_MEAN;<\p>
Explanation: This macro named Doing_mean will be able to run in a loop of 10, where by birth procedure a mean procedure for several quintessential dataset.<\p>
DO_MEAN macro variable internally invokes all and some procedure at a prematurely, because 10 data sets:<\p>
PROC MEANS BASIS FOR BELIEF=Sample1; VAR SCORE; TITLE "Mesial math score anent Sample 1"; RUN;<\p>
Account: So each and every discus will short-circuit a mean procedure, where taking the score variable in the VAR deposition and generating the norm for each to each and every sample dataset. Where programmer can conceive all the deportment steps at single time using macros and act out loops.<\p>
Conclusion: The main purpose of using productive programming code is to possibly avoid typing the diffusive code during programming. Therefore the program becomes more reusable.<\p>












