how to creat macro variable in proc sql

Accepted Solution Solved
Reply
Regular Contributor
Posts: 159
Accepted Solution

how to creat macro variable in proc sql

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;

 


Accepted Solutions
Solution
‎03-05-2018 03:18 PM
Super User
Posts: 10,272

Re: how to creat macro variable in proc sql


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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Super User
Posts: 10,272

Re: how to creat macro variable in proc sql

proc sql noprint;
select count (distinct internal_visit_id) into :counttime
from &visit.1
where Earliest_Visit_Date ne .;
quit; 
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 159

Re: how to creat macro variable in proc sql

Posted in reply to KurtBremser

you haven't helped me with what to do with the other variables that I have to select but without creating macros for them 

Solution
‎03-05-2018 03:18 PM
Super User
Posts: 10,272

Re: how to creat macro variable in proc sql


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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 13,574

Re: how to creat macro variable in proc sql

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 109 views
  • 0 likes
  • 3 in conversation