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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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