BookmarkSubscribeRSS Feed
mkeintz
PROC Star

@omer2020: you're not answering @Peter_C's question.  He is asking whether you want a series of rolling 36-month windows, or just the most recent 36-month window.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Peter_C
Rhodochrosite | Level 12
Should the output consist of 37 rows for each set of firm returns, so it would be keyed by firm and "relevant current date" and "historic date"?
A "set" consists of some kind of panel of the returns in each of the 36 consecutive months leading up to the "current date".
Given date range 1960 to 2020 is so narrow (just 720 elements for an array of the months), it would not be memory intensive to collect returns for all months in a temporary array, then digest that array to create what appears *might* be the required output.
One preliminary to that final stage...
....create a 720 byte string with 0/1 to indicate that a return is present for the month
....and search that for the first (and each) occurrence of REPEAT('1', 36)
This might more conveniently, indicate where each 37x'1' starts.

omer2020
Obsidian | Level 7

Hi,

First I want to apologize for late response especially to @art297 @mkeintz @Peter_C. It was my first post on this forum and as english being my second language, I lack to fully explain my issue and understand ur helpful feedback cent percent.

 

What I was looking for, wasn't rolling window. My panel data has monthly observatons for each firms. First code remove all those firms having less than 36 observation, but it dont account for consectiveness.

proc sql;
 create table mergeRET1 as select * from merge2
 group by permno having count(ret) ge 36;
 quit;

Adding these lines to macro code which I posted originally in first message do this:

    if first.permno then count=1;
    do i=count to 36; lagret[i] = .;
    end;
 count+1;
 if lagret36 = . then delete;

This will remove all returns observations, for which 36th lagged value is missing. I was wrong to assume that this is reducing my data, as I was assuming that the right way is, to have all return observation for firms, having more than 36 observation (and there I confused most of you). The correct way is: regardless of firm observation count, any return value, current or past (lets say januany 2017) having previuos 36 months of data, (lets say previous monthly data is available back to january 2014) should be included. And if any single observation (montly return) is missing in last 36 months, then simply it should be dropped.

 

This above codes do exactly the same. But I realize that too lately. I tried to remove the post, since my question itself was flawed, but I wasn't able to find any option to remove my original post. And things respectful members have suggested, it was hard for me to understand and respond as starter. Still I find my behaviour very unprofessional and want to appologize for late reply.

I really want to thank @Peter_C @mkeintz @art297 for taking time to reply me back and trying best to help me out. I will try to be more clear and precise next time I will post something.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 17 replies
  • 1627 views
  • 6 likes
  • 4 in conversation