How do i assign the SINGLE output of an step to a variable inside a macro?
E.G: There is only one distinct value of a character variable in a dataset. I want to assign that Distinct Value to 't';
Please Help, How Can We Do It?
It's like i want:
%Let t = %Eval(Proc Sql; Select Distinct(XYZ) From Prq; Quit;)
proc sql;
Select Distinct(XYZ) into : T
From Prq;
Quit;
%put &T ;
proc sql;
Select Distinct(XYZ) into : T
From Prq;
Quit;
%put &T ;
SQL will do that for you. Include a separator, just in case there is more than one possible value for XYZ:
proc sql;
select distinct xyz into : t separated by ' ' from Prq;
quit;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.