BookmarkSubscribeRSS Feed
PV15
Calcite | Level 5

Here is my requirement:

HAVE

EMP IDSALARY1SALARY2QTY
AB10011001011
AB10012001022
CD10021001011
CD10022001022
CD10023001033
EF10034001011
EF10035001022
GH10046001011
GH10047001022
GH10048001033
GH10049001044

 

WANT:

 

 EMP IDSALARY1SALARY2QTY
 AB10011001021
 AB10012001012
New recordAB10012001023
 CD10021001011
 CD10022001032
 CD10023001023
New recordCD10023001036
 EF10035001011
 EF10034001022
New recordEF10035001023
 GH10046001011
 GH10047001022
 GH10049001033
 GH10048001044
New recordGH100490010410
3 REPLIES 3
andreas_lds
Jade | Level 19

What have you tried so far?

I would use a data-step with BY-statement and RETAIN to save max-values of the salary-variables and the sum of qty. Checking first.EMP to reset retained variables and last.EMP to output the additional observation.

PV15
Calcite | Level 5

I have tried using .FIRST and .LAST and saving the value in temp variable. The logic is working fine, if there are only 2 same EMPID's , but my requirement is for more than 2 EMPID's.

 

andreas_lds
Jade | Level 19

@PV15 wrote:

I have tried using .FIRST and .LAST and saving the value in temp variable. The logic is working fine, if there are only 2 same EMPID's , but my requirement is for more than 2 EMPID's.

 


Please post the code using the "Insert SAS Code" button!

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