Syntax, INTO clause:
PROC SQL <options>;
SELECT column-1 <,...column-n>
INTO: macro-variable-specification-1 <...,
:macro-variable-specification-n>
QUIT;
macro-variable-specification
names one or more macro
variables to create or update. Precede each macro variable name with
a colon (:).
|
proc sql;
select avg(Salary)
into:avgSal
from certadv.payrollmaster;
quit;
title "Salaries above: &AvgSal"; proc sql; select EmpID, JobCode, Salary, DateofHire from certadv.payrollmaster where Salary>&avgSal and DateofHire>'01JAN2015'd; quit;
title "Salaries above: %left(%qsysfunc(putn(&AvgSal,dollar16.)))";
Syntax, %PUT statement:
%PUT text;
text
is any text string.
|
%put avgsal=&avgSal;
avgSal=54079.62
%put &=AvgSal;
and receive the same
value for the macro variable as above.
Syntax, INTO clause:
PROC SQL <options>;
SELECT column-1 <,...column-n>
INTO: macro-variable-specification-1 <...,
:macro-variable-specification-n> TRIMMED
QUIT;
|
proc sql; select min(PointsEarned) into:MinMiles from certadv.frequentflyers; quit; %put &=MinMiles;
MINMILES= 146
proc sql;
select min(PointsEarned)
into:MinMiles trimmed
from certadv.frequentflyers;
quit;
%put &=MinMiles;
MINMILES=146
Syntax, INTO clause:
PROC SQL <options>;
SELECT column-1 <,...column-n>
INTO: macro-variable-1 <...,
:macro-variable-n> SEPARATED
BY “delimiter”
QUIT;
delimiter
is enclosed in quotation
marks and specifies the character that is used as a delimiter in the
value of the macro variable.
|
proc sql noprint;
select distinct location into: sites separated by ' '
from certadv.schedule;
quit;
title1 "Total Revenue";
title2 "from Course Sites: &sites";
proc means data=certadv.all sum maxdec=0;
var fee;
run;
proc sql noprint; select avg(Census_Apr2010) as No_Format, avg(Census_Apr2010) as Format format=comma16. into:CensusAvg2010, :CensusAvg2010_Format from certadv.census; quit;
proc sql noprint; select State format=$upcase23. as State into:StateList separated by ', ' from certadv.census where PopEst_Apr2018>&CensusAvg2010 and PopEst_Apr2018>10000000 order by State ; quit; %put &=StateList;
ARIZONA, CALIFORNIA, FLORIDA, GEORGIA, ILLINOIS, INDIANA, MARYLAND, MASSACHUSETTS, MICHIGAN, MISSOURI, NEW JERSEY, NEW YORK, NORTH CAROLINA, OHIO, PENNSYLVANIA, TENNESSEE, TEXAS, VIRGINIA, WASHINGTON
title "States with Population Estimates Above Census Avg: &CensusAvg2010_Format"; footnote "&StateList"; proc sql; select strip(State) format=$upcase23. as State, Census_Apr2010 format=comma12., PopEst_Apr2010 format=comma12., (PopEst_Apr2018-Census_Apr2010) format=comma12. as PopChange from certadv.census where PopEst_Apr2018>&CensusAvg2010 and PopEst_Apr2018>10000000 order by State; quit; title; footnote;
52.14.174.133