BookmarkSubscribeRSS Feed
sasphd
Lapis Lazuli | Level 10

hello

I have this program to calculate the variable flux. I want that the program begin the calculation only after 3 missing value for each id (rank_no here)

data flux1;
set JOINT_Ftna2;
by rank_no;
rtri=((mret))*(lag1(mret))*(lag2(mret))-1;
flux=(new_TNA_LATEST-lag3(new_TNA_LATEST)*(1+rtri))/lag3(new_TNA_LATEST);

run;

Have

CALDT Rank_NO CRSP_FUNDNO MRET new_TNA_LATEST rtri
1985-02-28 1 53 1,00062422 39,2  
1985-03-29 1 53 1,00935745 39,2  
1985-04-30 1 53 1,00061805 39,2 0,01061174
1985-05-31 1 53 1,05514655 39,2 0,06567826
1985-06-28 1 53 1,02113917 39,2 0,07811738
1985-07-31 1 53 1,00115009 39,2 0,07869063
1985-08-30 1 53 0,99478865 39,2 0,01698593
1985-09-30 1 53 0,98020955 39,2 -0,02377722
1997-09-30 2 103 1,05448301 113,689 0,1056362
1997-10-31 2 103 0,97858404 113,689 0,02168359
1997-11-28 2 103 1,02221451 113,689 0,0548234
1997-12-31 2 103 1,00469527 49,983 0,00501959
1998-01-30 2 103 0,9622905 49,983 -0,01171411
1998-02-27 2 103 1,09756894 49,983 0,06113921
1998-03-31 2 103 1,03639974 49,983 0,09462485
1998-04-30 2 103 1,01915709 49,983 0,15931173

 

 

want

CALDT Rank_NO CRSP_FUNDNO MRET new_TNA_LATEST rtri flux
1985-02-28 1 53 1,00062422 39,2    
1985-03-29 1 53 1,00935745 39,2    
1985-04-30 1 53 1,00061805 39,2 0,01061174  
1985-05-31 1 53 1,05514655 39,2 0,06567826 -0,06567826
1985-06-28 1 53 1,02113917 39,2 0,07811738 -0,07811738
1985-07-31 1 53 1,00115009 39,2 0,07869063 -0,07869063
1985-08-30 1 53 0,99478865 39,2 0,01698593 -0,01698593
1985-09-30 1 53 0,98020955 39,2 -0,02377722 0,02377722
1997-09-30 2 103 1,05448301 113,689 0,1056362  
1997-10-31 2 103 0,97858404 113,689 0,02168359  
1997-11-28 2 103 1,02221451 113,689 0,0548234  
1997-12-31 2 103 1,00469527 49,983 0,00501959 -0,56537283
1998-01-30 2 103 0,9622905 49,983 -0,01171411 0,01171411
1998-02-27 2 103 1,09756894 49,983 0,06113921 -0,06113921
1998-03-31 2 103 1,03639974 49,983 0,09462485 -0,09462485
1998-04-30 2 103 1,01915709 49,983 0,15931173 -0,15931173
1 REPLY 1
ballardw
Super User

You missed a step. What exactly do you mean by missing value in: " I want that the program begin the calculation only after 3 missing value for each id (rank_no here)"?

Your Have data does not show any "missing values" for 3 of anything. The most you show is two missing values of RTRI for Rank_no=1.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 329 views
  • 0 likes
  • 2 in conversation