60 likes | 160 Views
Creating Macro Variables from PROC SQL. Presented by Faisal Dosani. Standard SQL Statement . PROC SQL; SELECT myVar FROM myDataset WHERE ID = 1 ; QUIT;. Macro Facility with SQL Statement . PROC SQL; SELECT myVar INTO :myVar FROM myDataset WHERE ID = 1 ; QUIT;.
E N D
Creating Macro Variables from PROC SQL Presented by Faisal Dosani
Standard SQL Statement PROC SQL; SELECT myVar FROM myDataset WHERE ID = 1 ; QUIT;
Macro Facility with SQL Statement PROC SQL; SELECT myVar INTO :myVar FROM myDataset WHERE ID = 1 ; QUIT; You can now use &myVar. in your code after running this SQL statement
Multiple variables are Selected PROC SQL; SELECT myVar, anotherVar INTO :myVar, :anotherVar FROM myDataset WHERE ID = 1 ; QUIT; You can now use &myVar and &anotherVar. in your code after running this SQL statement
Multiple rows are returned PROC SQL; SELECT myVar INTO :myVar1 THROUGH :myVar10 FROM myDataset ; QUIT; SAS will create multiple macro variables name &myVar1 to &myVar10.
Using separators PROC SQL; SELECT myVar INTO :myVar SEPERATED BY ‘ , ’ FROM myDataset ; QUIT; SAS will create one macro variable which has all the rows separated by ,