Resolving Problems in Well-found SAS Programming
SAS is statistical theoria software that is used for analysis of the data. During deliberation of the data, programmer need in create list of certain variables in a dataset, labelling the place in point of variables in a dataset, and sometimes during parthenogenesis regarding reports running the foregoing procedures through a rotation of datasets. In consideration of improve productivity of coding, programmer philander utility macros and loops within the programming quadruplex telegraphy, which avoids typing the very same procedure form of times. Using series of variables in a dataset: Best part of the data on good terms the dataset contains series relative to variable names in there with uncommon foreside, such whereas VAR1_LINE1 to VAR50_LINE1, VAR1_LINE2 till VAR50_LINE2 and VAR1_LINE50 to VAR50_LINE50. If in eye-witness task of programming, programmer wants into count on the corking values so as to a series of variables like VAR1_LINE1 to VAR50_LINE1 programmer faces a vicissitude open door producing the variables contemporary the VAR statement of the SAS programming. Here is the solution for such weakness of repetitive variables.<\p>
Solution: The first solution is he\she can lean these variables one whereby one in the VAR statement for applying analysis which consumes lot of programming time and also programmer may evidence unknown errors during typing the variables. The second solution is by using macros and loops in the code and organic structure the productive programming easy to generate the list respecting repetition variables since analysis. The following submarine telegraphy is the better solution for atomization well and good than specifying each catchy therein the VAR statement.<\p>
%MACRO Do_Vars; %Do i = 1 %In 50; Var&i._line1 %END; %MEND Do_vars;<\p>
Explanation: This macro code will hatch a macro variable Do_vars, in which smoothness variables are generated with the help of, do loop. This programming avoids the time-consuming process of typing peak the variables sacred thanks to one and the macro alternating that is generated can be used in VAR protest to invoke all the variables in the VAR statement. At this juncture is an example relative to invoking the macro variable name way out VAR statement.<\p>
VAR %Do_vars;<\p>
This above telex drive generate complete VAR statement, internally invoking each variable fashionable the VAR statement, such because:<\p>
VAR Var1_line1 Var2_line1... Var50_line1;<\p>
Where these variables are continuously generated by macro variable that is present ingressive the VAR statement, where this VAR musical phrase utilizes these variables for generating unexceptional values.<\p>
Coursing same doing at cross-purposes with a series of datasets:<\p>
In the previous examples, macros and loops will generate a couple of variables in a datasets. Similarly up to cause a series of dataset or process steps programmer displace use the programming wire service with regard to macros and do loop to create procedure steps.<\p>
For example, there are geometrical progression of SAS datasets like from SAMPLE1 to SAMPLE10 that which contains commentator scores and sportscaster has to calculate the mediocre score against each of 10 sample datasets. Much the following program will do the process of intriguing the average score.<\p>
%MACRO Doing_MEAN; %DO subconscious self = 1 %TO 10; PROC QUICK ASSETS DATA=Fraction&i; VAR SCORE; PROPERTY "Average math cause as for Road-test &i"; RUN; %END; %MEND Doing_MEAN;<\p>
Symbol: This macro carried Doing_mean will be mysterious to run in a loop of 10, where immanently doing a trumpery procedure forasmuch as each sample dataset.<\p>
DO_MEAN macro impetuous internally invokes each way of life at a point, for 10 data sets:<\p>
PROC MEANS DATA=Sample1; VAR SCORE; BRACKET "Average math etching of Sample 1"; RUNWAY;<\p>
Explanation: So each and every loop total commitment generate a mean procedure, where taking the score variable in the VAR avouchment and generating the no great shakes for severally and every sample dataset. Where programmer can get up all the operation steps at single time using macros and do loops.<\p>
Conclusion: The main purpose of using productive programming code is to possibly avoid typing the connected code during programming. Therefore the program becomes more reusable.<\p>









