Offtrack a little bit, based on the data given above, do you know how can I adjust the code to achieve three other columns in the output called p_us,up_us, and nosh where p_us, up_us, and nosh are the value of p_us, up_us, and nosh of the last day of the year associated with amihud.
To be more clear, from my data input (file data_almihud_) attached below, when running the code as below:
*I got year by using the code year= year(date);
proc sort data=amihud_;
by Type year;
run;
proc means data=amihud_ mean noprint;
var amihud;
by Type year;
output out=amihud_f n=obs mean=amihud;
run;
I have the result as below:
Type year _TYPE_ _FREQ_ obs amihud
134495 2016 0 261 15 0.0002618879
134495 2017 0 260 20 0.0002209701
134495 2018 0 261 4 0.0002583137
134495 2019 0 261 0 .
.
.
992438 2017 0 260 0 .
992438 2018 0 261 0 .
992438 2019 0 261 0 .
I am wondering what should I add into this code to have three other columns in the output called p_us,up_us, and nosh where p_us, up_us, and nosh are the values of p_us, up_us, and nosh of the last day of every year from the input data(associated with variable amihud)
I mean, I want the output as below
Type year _TYPE_ _FREQ_ obs amihud p_us up_us nosh
134495 2016 0 261 15 0.0002618879
134495 2017 0 260 20 0.0002209701
134495 2018 0 261 4 0.0002583137
134495 2019 0 261 0 .
.
.
992438 2017 0 260 0 .
992438 2018 0 261 0 .
992438 2019 0 261 0 .
I suggest this way of doing because I think that after we have such results containing variables "amihud", "p_us", "up_us", and "nosh", it is easier and clearer to generate the code satisfying the three conditions I mentioned above.
Many thanks and crossing my fingers.
... View more