Hi SAS community,
Thank you for your dedicated helps recently, I learn a lot from it, I will try my best to upgrade my skills better to help the others in the future.
Now, I have the data as below:
.
.
.
.
while Type is the column of different stocks (character variables), others are numeric variables (daily data from1/1/1987 to 31/12/2019).
From this dataset have, I want to get the data of p_us, up_us, nosh at the end of each year for each stock (distinct Type).
My code is as below:
data want ;
set have;
by Type year;
if last.year then
do;
p_us_=p_us;
vo_=vo;
nosh_=nosh;
end;
else delete;
run;
And when summarising the results that I receive, I saw that the data for vo, trading_vol, amihud, vo_ ends up with 0 observation as the proc means indicates below:
proc means data=have;
title"have";
run;
proc means data=want;
title"want";
run;
I also check my logic in my code but cannot find out the reason why it ends up like that, can you please have a look and point me out what should be the possibilities of such a result?
Thanks in advance!
Your data step keeps only the very last observation of each year for a type. Looks like your variables are always missing on these last observations.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.