Macro 6

<<< Click here to go back


Let's now explore the third method for creating global macro variables :

3. Proc SQL : Select Into Method :

As mentioned on the previous page, the task can be performed without sorting the data using this method.

Proc SQL ;
select name into : topper from marks_data
having marks = max(marks) ;
Quit ;

%put Topper of the class is : &topper.   ;



There are multiple usage of this method :

We can assign multiple macro variables at once.



Proc SQL ;
select name, marks into : topper , :max_marks from marks_data
having marks = max(marks) ;
Quit ;

%put Topper of the class is : &topper.  and she has secured &max_marks.  marks ;


We can also create a list in a macro variable :

Proc SQL ;
select distinct name  into : list separated by "," from marks_data  ;
Quit ;

%put Students in class are &list. ;



Click here to go next >>>


No comments:

Post a Comment

Do provide us your feedback, it would help us serve your better.