필터 지우기
필터 지우기

I only want to include the observations that have observations through the whole timeframe.

조회 수: 2 (최근 30일)
I have 979588 x 12 table with US stocks from 1963 - 2011. It's a total of 6411 different stocks. I want to remove all the stocks that have not been listed the entire time. The first column is an identification number for the specific stock called permno. If sum(permno == 10000) is 588, where 10000 is the identification number, it means the stock with id 10000 has been listed the whole time. So I want to remove all the stocks that don't meet the criteria: sum(permno == 10000) is 588. How do I go about this?

채택된 답변

dpb
dpb 2021년 7월 22일
NFULL=588; % the full file number -- use variables instead of "magic numbers" in code
tSave=groupfilter(tTable,'Permnoco',@(x)numel(x)==NFULL,'Permnoco');
You didn't tell us what the variable name is for the table; substitute that in for "tTable" above.
The variable name according to the above image is 'Permnoco' not 'permno'; obviously also use the correct name inside the table.
See doc groupfilter for details on the syntax.
  댓글 수: 6
Peter Perkins
Peter Perkins 2021년 7월 26일
There's probably a half dozen simple-ish ways to do this, but kudos to dpd for spotlighting the relatively new groupfilter. Exactly what it is aimed at!
dpb
dpb 2021년 7월 26일
Yeah, it's indeed abrightidea® and nice addition, Peter...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Financial Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by