BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mitrakos
Obsidian | Level 7

Hi Everyone,

 

I have a proc sql table that outputs the dataset below: 

proc sql; 
create table testtable as
	select sum(numerator) as n, 
	sum(denominator1) as d1,
	sum(denominator2) as d2, 
	sum(denominator3) as d3, 
	sum(denominator4) as d4
	from work.responserate_sex;
quit;

Which outputs as: 

nd1d2d3d4
93663.

 

I am trying to create a new variable called result which would be written as 
result = n / ((d1 + d2) - (d3) + (d4))

data testtable;
set testtable;
result = n / ((d1 + d2) - (d3) + (d4));
run;

this outputs a blank cell for the new variable result and I'm not sure why. Can anyone help me out as to why this may be the case?  

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
When you sum missing values with the sum operator it returns missing. If you use the SUM() function then it returns a value.

9 + . = . for sum operator (+)
Sum(9, .) = 9 for sum function.


result = n / sum(sum(d1, d2), - 1*d3, d4));

View solution in original post

2 REPLIES 2
Reeza
Super User
When you sum missing values with the sum operator it returns missing. If you use the SUM() function then it returns a value.

9 + . = . for sum operator (+)
Sum(9, .) = 9 for sum function.


result = n / sum(sum(d1, d2), - 1*d3, d4));
mitrakos
Obsidian | Level 7
I see! This worked perfectly. Thank you!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1064 views
  • 0 likes
  • 2 in conversation