Is there a statement in SAS equivalent to MS SQL's "Select x" that will display the value of x, with no FROM nor WHERE clauses, just SELECT variable?
I'm not looking for the %PUT statement.
Thanks.
x is a variable that has been calculated prior to the select statement. You can also say SELECT DATE() or any function. It's probably a T-SQL statement more than a pure SQL statement. And I don't know if it works in MySQL. MS SQL/T-SQL sure does.
I doubt that any actual SQL will display a value without something to indicate a source. Where would MySQL find the value??
SAS will require a FROM to indicate a source;
SAS will allow you to use FROM _last_ to reference the last created data set as the source of data if for some reason you do not know the actual name of a data set. Of course, if that data set does not contain the specified variable then that is going to generate a variable not found error.
data junk; x='abc'; run; proc sql; select x from _last_ ; quit;
x is a variable that has been calculated prior to the select statement. You can also say SELECT DATE() or any function. It's probably a T-SQL statement more than a pure SQL statement. And I don't know if it works in MySQL. MS SQL/T-SQL sure does.
@jffeudo86 wrote:
x is a variable that has been calculated prior to the select statement. You can also say SELECT DATE() or any function. It's probably a T-SQL statement more than a pure SQL statement. And I don't know if it works in MySQL. MS SQL/T-SQL sure does.
SAS Proc SQL is basically ANSI standard with some specific functions (not features such as this) implemented.
Something in the environment of that specific is using an implied FROM when one is not supplied. But SAS does not support that type of behavior.
I think that not knowing where a value may come from is problematic.
I don't think I have even used an intentional or implied _LAST_ reference except for demonstration code on this forum in the past 10 or more years.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.