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

Hi all, 

I have a quick simple question.

 

data have;

input Id a b  ;

1 2  2

1 2  2

1 3  2

2 4  .

2 4  .

;

run;

 

Proc sql; 

Create table want as Id, a, sum(b) as new from have group by ID, a; quit;

 

This code does not account for the missing B. it means in "want table" it does not give the ID2.

If I merge the want table with the "have table'  my problem will solve. However, I was wonder if I can count for the missing directly in this code. So the data have should be like below:

 

data want;

input Id a new  ;

1 2  4

1 3  2

2 4  .

;

run;

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

As far as I can see this gives you the "WANT" result you want:

 

Proc sql; 
Create table want as 
select Id, a, sum(b) as new 
from have 
group by ID, a; 
quit;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

As far as I can see this gives you the "WANT" result you want:

 

Proc sql; 
Create table want as 
select Id, a, sum(b) as new 
from have 
group by ID, a; 
quit;
ali_far
Obsidian | Level 7
Thanks for your reply.

I just tested the code here and it works for my sample data! You are right..
However, dont know why it does work ( I mean the way I want) for my real data..

I need to recheck other things perhaps...

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 588 views
  • 0 likes
  • 2 in conversation