I have this code in proc sql and I want to create a macro variable for only one raw of the variable counttime
I saw some methods to create macro variable for all the variables that selected but I don't know how to do it for only a variable.
select internal_visit_id, Earliest_Visit_Date, count (distinct internal_visit_id) as counttime
from &visit.1
where Earliest_Visit_Date ne .;
quit;
@mona4u wrote:
you haven't helped me with what to do with the other variables that I have to select but without creating macros for them
Those variables are not needed at all for the creation of the single macrovar. They only get in the way.
proc sql noprint;
select count (distinct internal_visit_id) into :counttime
from &visit.1
where Earliest_Visit_Date ne .;
quit;
you haven't helped me with what to do with the other variables that I have to select but without creating macros for them
@mona4u wrote:
you haven't helped me with what to do with the other variables that I have to select but without creating macros for them
Those variables are not needed at all for the creation of the single macrovar. They only get in the way.
It will really help if you provide some example data, the result of your existing query would be fine, and indicate what you want to go into which macro variable.
It isn't very clear what you mean by "only one raw of the variable counttime". Do you want the first, last, something else? Since there is going to be one value of counttime for each level combination of interternal_visit_id and earliest_visit_date we need to know which one you want.
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.