BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Agent1592
Pyrite | Level 9

Dear Sas Community:

I have the data for which for stock returns are in separate columns.

The have data is:

Date863486487203
1/29/2010-11.2195-0.35997-10.2828
2/26/20103.3333310.3654-13.9535
3/31/201012.9032314.1891812.46246
4/30/2010-0.724641.012504-2.78515
5/31/2010-12.6521-14.2099-10.5048
6/30/2010-2.85714-10.6685

-6.66667

 

I would like to convert this into a panel data with the following format:

DateTickerReturn
1/29/20108634-11.2195
2/26/201086343.33333
3/31/2010863412.90323
4/30/20108634-0.72464
5/31/20108634-12.6521
6/30/20108634-2.85714
1/29/20108648-0.35997
2/26/2010864810.3654
3/31/2010864814.18918
4/30/201086481.012504
5/31/20108648-14.2099
6/30/20108648-10.6685
1/29/20107203-10.2828
2/26/20107203-13.9535
3/31/2010720312.46246
4/30/20107203-2.78515
5/31/20107203-10.5048
6/30/20107203-6.66667

 

Can someone please help. 

data WORK.HAVE;
  infile datalines dsd truncover;
  input Date:MMDDYY8. v8634:32. v8648:32. v7203:32.;
  format Date MMDDYY8.;
datalines4;
01/29/10,-11.219513,-0.3599703,-10.282779
02/26/10,3.33333,10.3654,-13.953489
03/31/10,12.903225,14.189184,12.462461
04/30/10,-0.7246375,1.012504,-2.785146
05/31/10,-12.652069,-14.209908,-10.504776
06/30/10,-2.857143,-10.668468,-6.666666
07/30/10,1.176476,-7.785338,-0.9740233
08/31/10,3.19767,-14.836067,-6.229508
09/30/10,-7.042253,3.773582,2.320814
10/29/10,-8.636361,-17.93042,-7.024389
11/30/10,12.603653,3.043473,12.626791
12/31/10,3.092778,15.506327,0
01/31/11,5.142856,3.105021,5.590057
02/28/11,4.347825,1.950359,12.684369
03/31/11,-5.598956,-2.69565,-12.303662
04/29/11,1.7931,-5.277526,-0.7680476
05/31/11,-6.097561,-7.300675,5.263162
06/30/11,-4.761905,-5.473685,-0.9009004
07/29/11,0,-13.590032,-3.516817
08/31/11,-15.406251,-16.90695,-13.3439
09/30/11,-15.035093,-24.65754,-1.212788
10/31/11,19.91304,14.343429,-1.636904
11/30/11,-14.145607,-27.52293,-4.673254
12/30/11,15.114236,7.594931,2.231967
01/31/12,13.320613,29.41177,9.551657
02/29/12,6.769955,15.070927,18.21705
03/30/12,26.18296,22.34206,6.408346
04/30/12,4.25,-15.99496,-7.422972
05/31/12,-30.45564,-14.842576,-8.018154
06/29/12,7.068968,10.683012,3.571427
07/31/12,-14.975845,-9.810125,-5.329156
08/31/12,13.257575,7.7193,2.483439
09/28/12,3.010035,8.280253,-4.402518
10/31/12,6.006491,6.76471,0.8223653
11/30/12,1.071978,12.307692,17.24709
12/31/12,19.697,23.91033,13.295614
01/31/13,6.329119,2.613068,8.988762
02/28/13,14.730537,1.81644,10.428739
03/29/13,3.757834,9.201872,1.993704
04/30/13,-5.835009,4.643166,16.04939
05/31/13,25.641,14.297449,6.560278
06/28/13,-3.954804,-5.481482,-3.542674
07/31/13,5.882359,11.677111,-0.3338873
08/30/13,-7.407409,-3.916085,-2.141678
09/30/13,3.999996,-1.382822,5.555558
10/31/13,-1.538461,1.992619,1.435411
11/29/13,10.056925,16.96751,1.754391
12/31/13,3.620684,1.234567,0.6269574
01/31/14,-3.494179,5.853653,-7.757008
02/28/14,-5.862069,-2.517563,-2.974409
03/31/14,14.285719,5.1051,-0.2226412
04/30/14,-7.051283,-8.888888,-4.649955
05/30/14,-3.103447,-2.814257,4.441619
06/30/14,3.736651,-1.093954,5.606663
07/31/14,1.372218,2.797663,0.8711338
08/29/14,-0.9615362,5.886078,-3.342575
09/30/14,5.98706,9.742975,9.024965
10/31/14,-3.358781,2.941179,0.541544
11/28/14,16.20295,13.043475,18.50291
12/31/14,6.056333,7.49507,3.336072
01/30/15,-13.944221,-17.38532,1.151097
02/27/15,13.063765,1.165259,3.04153
03/31/15,-0.2751052,-1.989532,3.968751
04/30/15,,2.794516,-0.807023
05/29/15,,10.580027,1.045215
06/30/15,,0.5342364,-4.660625
07/31/15,,8.792269,0.609529
08/31/15,,-13.27709,-12.855929
09/30/15,,-6.917292,-5.104822
10/30/15,,11.470116,7.143879
11/30/15,,3.816426,2.517068
12/31/15,,-2.652395,-2.20713
01/29/16,,-21.11111,-3.407568
02/29/16,,-12.369871,-18.09722
03/31/16,,4.8218,0.9326816
04/29/16,,2.580643,-8.1248
05/31/16,,4.276729,2.28157
06/30/16,,-15.238678,-11.071992
07/29/16,,12.044609,15.139675
08/31/16,,9.489048,5.836439
09/30/16,,-5.12979,-6.579375
10/31/16,,13.224756,5.191207
11/30/16,,28.09497,10.028135
12/30/16,,13.680494,3.444123
01/31/17,,0.5434752,-4.2745
02/28/17,,2.040815,-5.056685
03/31/17,,-3.636366,-5.074626
04/28/17,,2.755904,-2.943069
05/31/17,,,-1.706713
06/30/17,,,-1.471329
07/31/17,,,5.786526
08/31/17,,,-0.8180916
09/29/17,,,10.180628
10/31/17,,,4.172873
11/30/17,,,-0.4662991
12/29/17,,,2.283037
01/31/18,,,3.701651
02/28/18,,,-4.902732
03/30/18,,,-5.6669
04/30/18,,,5.216122
05/31/18,,,-3.620666
06/29/18,,,2.780962
07/31/18,,,1.882851
;;;;
1 ACCEPTED SOLUTION
2 REPLIES 2
Reeza
Super User
Did you try PROC TRANSPOSE?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 1181 views
  • 1 like
  • 3 in conversation