BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tSAS1
Obsidian | Level 7
Hello everyone,
 
I have a database like that :
ID
flag
A
1
A
1
A
1
A
1
A
21
A
1
A
1
B
1
B
1
B
7
B
1
B
1
B
1
B
30
B
1
B
1
B
1
B
1
B
1
 
 and I want to sum all the 1 values of flag variable separated with different numbers it to this form:
 
1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

Your data is a picture. Make it TEXT.

 

data test;
   input id y;
   cards;
1 1
1 1
1 2
1 1
1 1
1 1
1 3
1 1
2 1
2 2
2 1
2 1
2 1
2 3
2 1
;;;;
proc summary data=test nway missing;
   by id y notsorted;
   output out=test2(where=(y eq 1)) sum(y)=sumY;
   run;
proc print;
   run;

Capture.PNG

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19

Your data is a picture. Make it TEXT.

 

data test;
   input id y;
   cards;
1 1
1 1
1 2
1 1
1 1
1 1
1 3
1 1
2 1
2 2
2 1
2 1
2 1
2 3
2 1
;;;;
proc summary data=test nway missing;
   by id y notsorted;
   output out=test2(where=(y eq 1)) sum(y)=sumY;
   run;
proc print;
   run;

Capture.PNG

tSAS1
Obsidian | Level 7
Thank you
The code works successfully

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!

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
  • 608 views
  • 2 likes
  • 2 in conversation