DATA Step, Macro, Functions and more

Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

Accepted Solution Solved
Reply
Contributor
Posts: 26
Accepted Solution

Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

Hello,

 

Quick question for you guys: I basically want to create a macro variable called syserr1 that if greater than 0 will give me an error message in an other code.

Now, the code below creates my macro variable no problem, I was just wondering if it was possible to create ONLY one macro variable in my procedure instead of 3? (AKA no need to create &nobs and &nuniqid

 

proc sql;
	select count(distinct ID) as Nuniq, count(*) as Nobs, calculated Nobs - calculated Nuniq as diff 
	into :nobs, :nuniqid, :syserr1
		from Have
	;
quit;

Thank you


Accepted Solutions
Solution
‎11-23-2017 11:00 AM
Super User
Posts: 22,875

Re: Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

proc sql;
	select count(*) - count(distinct ID) into :syserr1
		from Have
	;
quit;

View solution in original post


All Replies
Super User
Super User
Posts: 9,227

Re: Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

I really don't understand your question.  If you only want one macro variable, then only select one data item:

proc sql;
  select count(distinct ID) 
  into :nobs
  from Have;
quit;

 

Contributor
Posts: 26

Re: Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

The macro variable that I need is the difference between the unique observations and the total number of observations. My third variable in the select clause creates this variable and is the only one that I need.
Solution
‎11-23-2017 11:00 AM
Super User
Posts: 22,875

Re: Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

proc sql;
	select count(*) - count(distinct ID) into :syserr1
		from Have
	;
quit;
Contributor
Posts: 26

Re: Selecting multiple variables in PROC SQL, but only creating one macro variable with into clause

I knew it was gonna be easy... Wow. Thank you very much for response time, Good day to you!
☑ This topic is solved.

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

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