BookmarkSubscribeRSS Feed
Zhongda
Fluorite | Level 6

Hi ALL,

Again, thank you so much for getting the help so far.

 

Currently, I am working on rebalance the portfolio, and make it ten groups. based on the monthly return of the stocks. Before I know how to rebalance it each month, but at this moment, I need to rebalance it using the market cap of each June as the weights for the coming one year. I do not know how to deal with it.

there are two difficulties here, 

First is how to deal with the missing value, for example, 

in June 1986 we have 10 stocks and according to the market cap you rank them from 1 to 10. but for July 1986, you may have some refill of the stocks, either the original 10 stocks could delist some or there are some new adding stock in July.

Second is how to use this weight for each June to group the data for next coming 12 month.

I upload a very simple dataset which the first problem is excluded, but I still would be more than happy if you can include the code that solve this first difficulty as well.

here is the dataset, please let me know if you have any suggestions, thanks a lot.

 

MTHCALDTPERMNOMTHCAPMTHRETyearmonth
1/31/8610000161000.70731719861
1/31/86100016033.1250.06521719861
1/31/861000213659.38-0.0106419861
1/31/8610003418000.18918919861
2/28/861000011960-0.2571419862
2/28/86100016156.250.02040819862
2/28/861000215568.750.13978519862
2/28/8610003422750.01136419862
3/31/8610000163300.36538519863
3/31/86100016217.8130.02535219863
3/31/861000216670.310.07075519863
3/31/861000341800-0.0112419863
4/30/861000015172-0.0985919864
4/30/86100016279.3750.00990119864
4/30/861000217551.560.05286319864
4/30/861000339187.5-0.062519864
5/30/861000011793.86-0.2226619865
5/30/86100016217.813-0.009819865
5/30/861000217184.38-0.0209219865
5/30/861000344792.5-0.0060619865
6/30/861000011734.59-0.0050319866
6/30/86100016033.125-0.0132419866
6/30/861000214907.81-0.1324819866
6/30/861000347523.750.06097619866
7/31/861000010786.34-0.0808119867
7/31/86100015971.563-0.010219867
7/31/861000215642.190.04926119867
7/31/861000342061.25-0.1149419867
8/29/86100004148.594-0.6153819868
8/29/86100016402.50.07216519868
8/29/861000215642.19019868
8/29/861000342607.50.01298719868
9/30/86100003911.531-0.0571419869
9/30/86100016317.625-0.0039719869
9/30/861000216743.750.07042319869
9/30/861000340149.38-0.0576919869
10/31/86100003002.344-0.24242198610
10/31/86100016565.3750.039216198610
10/31/861000215715.63-0.0614198610
10/31/861000345338.750.129252198610
11/28/86100003182.4840.06198611
11/28/861000169370.056604198611
11/28/861000215715.630198611
11/28/861000344246.25-0.0241198611
12/31/86100001981.547-0.37736198612
12/31/861000169370.016154198612
12/31/861000214540.63-0.07477198612
12/31/861000342061.25-0.04938198612
1/30/87100001581.531-0.2121219871
1/30/87100016689.25-0.0357119871
1/30/871000215935.940.0959619871
1/30/871000347523.750.1298719871
2/27/87100001581.531019872
2/27/87100016193.75-0.0740719872
2/27/871000215715.63-0.0138219872
2/27/8710003480700.01149419872
3/31/8710000973.25-0.3846219873
3/31/87100016317.6250.03748619873
3/31/871000215128.13-0.0373819873
3/31/871000348070019873
4/30/8710000912.4219-0.062519874
4/30/87100016069.875-0.0392219874
4/30/8710002152750.00970919874
4/30/871000345611.88-0.0511419874
5/29/8710000851.5938-0.0666719875
5/29/87100015636.313-0.0714319875
5/29/871000215862.50.03846219875
5/29/871000339985.75-0.1257519875
6/30/8710000851.5938019876
6/30/87100015822.1250.05268719876
6/30/871000215862.5019876
6/30/871000338890.25-0.027419876
7/31/871000159460.02127719877
7/31/8710002164500.03703719877
7/31/871000336973.13-0.049319877
8/31/87100016441.50.08333319878
8/31/871000215862.5-0.0357119878
8/31/871000339164.130.06514419878
9/30/87100016200-0.0216319879
9/30/871000214687.5-0.0740719879
9/30/871000337520.88-0.0419619879
10/30/871000163240.02198710
10/30/871000211750-0.2198710
10/30/871000329030.75-0.22628198710
11/30/87100016138-0.02941198711
11/30/871000211896.880.0125198711
11/30/8710003318130.113208198711
12/31/87100015828-0.03354198712
12/31/871000211750-0.01235198712
12/31/871000330716-0.03448198712

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 0 replies
  • 731 views
  • 0 likes
  • 1 in conversation