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!!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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