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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.