BookmarkSubscribeRSS Feed
ger15xxhcker
Quartz | Level 8

Hello!

 

This is my test table. I would have 3 questions.

 

ID   amt   

1   10

1   12

1   50

1   52

2   10 

2   11

2   13

3   60

3   65

3   120

 

1. If, after the first two occurrences, the difference is greater than 20% compared to the third one, then do one flg how can i do it?

2. Same table but I'd like to mark only if the amount fields do not change and always the same how can i do it?

3. Same table but I'd like to mark only if the amount fields always changeing. How can i do it?.(each is different)

 

ID   amt   

1   10

1   12

1   50

1   52

2   10 

2   11

2   13

3   60

3   65

3   120

 

1. eg:

new final table looks like:

Id flg

1 y

2 n

 

 

Thanks for your help!

 

2 REPLIES 2
Patrick
Opal | Level 21

I can't find the two questions but just 3 requirements. What have you tried already?

May be post the code you've got already (even if not working), a data step reading the data and then show us the desired result.

ger15xxhcker
Quartz | Level 8

Thank you for your guidance! Unfortunately I don't know how to start with it 😕

 

data test;
 input id amt;
 datalines;
 1 5
 1 5
 1 106
 2 90
 2 100
 3 111
 3 111
 3 111
 3 111
 4 837
 4 838
 4 839
 ;
run;

data want01; /*01 after the first two occurrences, the difference is greater than 20% compared to the third one*/
 input id flg$;
 datalines;
 1 Y
 ;
run;
data want02; /*02 where the amt field is constant*/
 input id flg$;
 datalines;
 3 Y
 ;
run;
data want03; /*03 where the amt field always changeing*/
 input id flg$;
 datalines;
 2 Y
 4 Y
 ;
run;

Thanks for your reply!

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