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.

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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