BookmarkSubscribeRSS Feed
Alexxxxxxx
Pyrite | Level 9

Hello all,

 

I am trying to get the same 'share_outstanding' for each 'firm_id', 'year' group,

based on following table1

data table1;
infile cards dsd dlm=",";
input
firm_id :$15.
year :8.
fundno :$15.
shares :8.
share_outstanding :8.
;
cards;
36110,2002, 14086, 18000, 32000000
36110,2002, 15056, 92000, 32000000
36110,2002, 15058, 4740, 32000000
36110,2002, 16500, 35300, 27000000
36111,2002, 1903, 26700, 31000000
36111,2002, 1909, 543350, 31000000
36111,2002, 19658, 60000, 30000000
36111,2002, 2021, 20000, 30000000
36111,2002, 2034, 59700, 31000000
;;;;
run;
I expect to get 

 

36110,2002, 14086, 18000,  32000000
36110,2002, 15056, 92000,  32000000
36110,2002, 15058, 4740,   32000000
36110,2002, 16500, 35300, 32000000
36111,2002, 1903,  26700,  31000000
36111,2002, 1909,  543350, 31000000
36111,2002, 19658, 60000,  31000000
36111,2002, 2021,  20000,  31000000
36111,2002, 2034,  59700,  31000000
by using first four lines as an example, 

 

in this group (i.e., same 'firm_id' and 'year', as firm_id=36110 and year=2002), share_outstaning has three '32000000' and one '27000000'. and then I expect to replace '27000000'  by '32000000' (i.e., set share_outsanding=32000000 when firm_id=36110 and year=2002), it is because I have more '32000000' than '27000000' in this group (firm_id='36110' , year=2002).

 

if more than one value is tied highest in the group then please keep them together.

 

for example,

"What if there are two of a certain value and two of another value?"

       --please keep them both, because both of them are the 1/2 (highest) in this group.

"What if all four are different?'

        --please keep all of them, because both of them are the 1/4 (highest) in this group.

could you please give me some advice about this .

thanks in advance.

 

 

 

 

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

What rules do you follow here, when the share_outstanding is not the same in each firm_id,year group? In the cases you provide, there is three of one value and one different value. What if there are two of a certain value and two of another value? What if all four are different?

 

The explanation in your text is different than the explanation in your Subject line.

 

Please clarify.

--
Paige Miller
Alexxxxxxx
Pyrite | Level 9

Hi, @PaigeMiller , many thanks for your reply.

 

in most case, share_outstanding is the same in each firm_id, year group.

 

I expect to remain the highest percentage of value in each group, and if more than one value is tied highest in the group then please keep them together.

 

"What if there are two of a certain value and two of another value?"

       --please keep them both, because both of them are the 1/2 (highest) in this group.

"What if all four are different?'

        --please keep all of them, because both of them are the 1/4 (highest) in this group.

 

PaigeMiller
Diamond | Level 26

Sure would be helpful if you could provide example data where these other situations actually occur.

--
Paige Miller
ballardw
Super User

Percentage of what???????

 

Your subject line makes no sense in terms of the data or example.

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