%macro minmaxchar(Var); proc sql; select min(&Var) as Minimum,max(&Var) as Maximum from work.result; quit; %mend minmaxchar; %macro minmaxloop(); data work.sc; set work.result; array Var _character_; do over Var; %minmaxchar(Var); end; run; %mend minmaxloop; this is my input (work.result): A B C D -------- 1 dv 4 t 3 aa 5 zz 2 cs 6 ac this is my wanted output Max Min ------- 3 1 dv aa 6 4 zz ac I am looking for a way to get the minimum and the maximum of each column (I want to make it work for both char and numeric columns), but I need to use the sql min() and max() instead of sas because sql min() max() can receive char as a parameter and compute the min and max as in ASCII order. The only problem with sql min()/max() is that it can only receive one argument at a time, so I would need to enter the column name in order for it to work. However, I want the code to be as dynamic as possible so I want a way to put in a macro variable as a parameter in the min/max function and have the macro variable be the iterator through all the columns. My code above does not work because the proc sql cannot be used within the looping data step. Please enlightened me experts.
... View more