/***************************************************************************************************************** SAS file name: select_into.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate the Select Into Clause in Proc SQL, Author: Peter Clemmensen Creation Date: 13/11/2020 This program supports the blog post "" on SASnrd.com *****************************************************************************************************************/ proc sql noprint; select name into :n from sashelp.class where name = 'Alfred'; quit; %put &=n.; /* Select Multiple Variables into Multiple Macro Variables */ proc sql noprint; select name, height into :n , :h separated by ' ' from sashelp.class where name = 'Alfred'; quit; %put &=n. &=h.; /* Select Multiple Values Into a Single Macro Variable */ proc sql noprint; select name into : n separated by ', ' from sashelp.class; quit; %put &n.; /* Create as many macro variables as values processed */ proc sql noprint; select name into : n1 - from sashelp.class; %let t = &sqlobs.; quit; %put &=n1.; %put &=n19.; %put &=t.; %macro putem; %do i = 1 %to &t.; %put &&n&i; %end; %mend; %putem;