BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@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.

View solution in original post

4 REPLIES 4
mona4u
Lapis Lazuli | Level 10

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

Kurt_Bremser
Super User

@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.

ballardw
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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