Dear Stata Users,
My dataset is in panel form. There are 6 variables: IssueCode, IssueName, InvestorCode (defines type of investor), BuyTradingValue, SellTradingValue, date.
I need to calculate sum of BuyTradingValue and SellTradingValue within IssueName and by a certain InvestorCode (I need to sum Buy/Sell of the following investors: (1000+2000+3000+4000+5000+6000+7000) and leave BuyTradingValue/SellTradingValue of the following investors as it is: 8000,9000.
I just have learnt collapse syntax and know that it can create summary statistics but struggling to implement it with a condition.
Here is my dataset:
May you please help me out with this task?
Thanks a lot in advance.
My dataset is in panel form. There are 6 variables: IssueCode, IssueName, InvestorCode (defines type of investor), BuyTradingValue, SellTradingValue, date.
I need to calculate sum of BuyTradingValue and SellTradingValue within IssueName and by a certain InvestorCode (I need to sum Buy/Sell of the following investors: (1000+2000+3000+4000+5000+6000+7000) and leave BuyTradingValue/SellTradingValue of the following investors as it is: 8000,9000.
I just have learnt collapse syntax and know that it can create summary statistics but struggling to implement it with a condition.
Here is my dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str12(IssueCode IssueName) int InvestoreCode double BuyTradingValue long SellTradingValue float date "HK0000050325" "CHINA OCEAN" 1000 0 0 19549 "HK0000050325" "CHINA OCEAN" 2000 0 0 19549 "HK0000050325" "CHINA OCEAN" 3000 0 0 19549 "HK0000050325" "CHINA OCEAN" 3100 0 0 19549 "HK0000050325" "CHINA OCEAN" 4000 0 0 19549 "HK0000050325" "CHINA OCEAN" 5000 0 0 19549 "HK0000050325" "CHINA OCEAN" 6000 0 0 19549 "HK0000050325" "CHINA OCEAN" 7000 0 0 19549 "HK0000050325" "CHINA OCEAN" 8000 431337690 366904090 19549 "HK0000050325" "CHINA OCEAN" 9000 55648150 128496750 19549 "HK0000050325" "CHINA OCEAN" 9001 8415000 0 19549 "KR7000020008" "DongwhaPharm" 1000 0 0 19549 "KR7000020008" "DongwhaPharm" 2000 0 0 19549 "KR7000020008" "DongwhaPharm" 3000 0 19445000 19549 "KR7000020008" "DongwhaPharm" 3100 0 0 19549 "KR7000020008" "DongwhaPharm" 4000 0 0 19549 "KR7000020008" "DongwhaPharm" 5000 0 0 19549 "KR7000020008" "DongwhaPharm" 6000 0 0 19549 "KR7000020008" "DongwhaPharm" 7000 0 0 19549 "KR7000020008" "DongwhaPharm" 8000 128101760 122247860 19549 "KR7000020008" "DongwhaPharm" 9000 31676400 18085300 19549 "KR7000020008" "DongwhaPharm" 9001 0 0 19549 "KR7000040006" "S&TMOTORS" 1000 0 0 19549 "KR7000040006" "S&TMOTORS" 2000 0 0 19549 "KR7000040006" "S&TMOTORS" 3000 0 0 19549 "KR7000040006" "S&TMOTORS" 3100 0 0 19549 "KR7000040006" "S&TMOTORS" 4000 0 0 19549 "KR7000040006" "S&TMOTORS" 5000 0 0 19549 "KR7000040006" "S&TMOTORS" 6000 0 0 19549 "KR7000040006" "S&TMOTORS" 7000 0 0 19549 "KR7000040006" "S&TMOTORS" 8000 22773105 18520385 19549 "KR7000040006" "S&TMOTORS" 9000 0 4252720 19549 "KR7000040006" "S&TMOTORS" 9001 0 0 19549 "HK0000050325" "CHINA OCEAN" 1000 17490 0 19550 "HK0000050325" "CHINA OCEAN" 2000 0 0 19550 "HK0000050325" "CHINA OCEAN" 3000 14650000 0 19550 "HK0000050325" "CHINA OCEAN" 3100 0 0 19550 "HK0000050325" "CHINA OCEAN" 4000 0 0 19550 "HK0000050325" "CHINA OCEAN" 5000 0 0 19550 "HK0000050325" "CHINA OCEAN" 6000 0 0 19550 "HK0000050325" "CHINA OCEAN" 7000 0 0 19550 "HK0000050325" "CHINA OCEAN" 8000 708832685 732554225 19550 "HK0000050325" "CHINA OCEAN" 9000 92420450 93745100 19550 "HK0000050325" "CHINA OCEAN" 9001 10378700 0 19550 "KR7000020008" "DongwhaPharm" 1000 0 0 19550 "KR7000020008" "DongwhaPharm" 2000 0 0 19550 "KR7000020008" "DongwhaPharm" 3000 0 19436000 19550 "KR7000020008" "DongwhaPharm" 3100 0 0 19550 "KR7000020008" "DongwhaPharm" 4000 0 0 19550 "KR7000020008" "DongwhaPharm" 5000 0 0 19550 "KR7000020008" "DongwhaPharm" 6000 0 0 19550 "KR7000020008" "DongwhaPharm" 7000 0 0 19550 "KR7000020008" "DongwhaPharm" 8000 157136730 159998530 19550 "KR7000020008" "DongwhaPharm" 9000 47412800 25115000 19550 "KR7000020008" "DongwhaPharm" 9001 0 0 19550 "KR7000040006" "S&TMOTORS" 1000 0 0 19550 "KR7000040006" "S&TMOTORS" 2000 0 0 19550 "KR7000040006" "S&TMOTORS" 3000 0 0 19550 "KR7000040006" "S&TMOTORS" 3100 0 0 19550 "KR7000040006" "S&TMOTORS" 4000 0 0 19550 "KR7000040006" "S&TMOTORS" 5000 0 0 19550 "KR7000040006" "S&TMOTORS" 6000 0 0 19550 "KR7000040006" "S&TMOTORS" 7000 0 0 19550 "KR7000040006" "S&TMOTORS" 8000 53985034 54552494 19550 "KR7000040006" "S&TMOTORS" 9000 952530 385070 19550 "KR7000040006" "S&TMOTORS" 9001 0 0 19550 end format %tdNN/DD/CCYY date
May you please help me out with this task?
Thanks a lot in advance.