How can i create a column vector that sotres PERMNO for all that had positive ret and name this column vector as sample?

2 visualizzazioni (ultimi 30 giorni)
PERMNO DateOfObservation prc ret Bid Ask shrout
______ _________________ _______ _________ _________ ______ _______
10026 20201231 155.37 0.072598 155.37 155.48 18954
10028 20201231 5.2 0.125541 5.21 5.25 26925
10032 20201231 78.21 0.046848 78.21 78.29 28823
10044 20201231 4.05 -0.051522 4.05 4.1 6071
10051 20201231 21.99 -0.030851 22.01 22.02 38109
10065 20201231 17.29 0.036571 17.29 17.3 108731
How can i create a column vector that sotres PERMNO for all that had positive ret and name this column vector as sample?

Risposte (1)

Voss
Voss il 20 Feb 2022
Modificato: Voss il 20 Feb 2022
% reproducing your table:
data = num2cell([ ...
10026 20201231 155.37 0.072598 155.37 155.48 18954
10028 20201231 5.2 0.125541 5.21 5.25 26925
10032 20201231 78.21 0.046848 78.21 78.29 28823
10044 20201231 4.05 -0.051522 4.05 4.1 6071
10051 20201231 21.99 -0.030851 22.01 22.02 38109
10065 20201231 17.29 0.036571 17.29 17.3 108731
],1);
t = table(data{:},'VariableNames',{'PERMNO' 'DateOfObservation' 'prc' 'ret' 'Bid' 'Ask' 'shrout'})
t = 6×7 table
PERMNO DateOfObservation prc ret Bid Ask shrout ______ _________________ ______ _________ ______ ______ __________ 10026 2.0201e+07 155.37 0.072598 155.37 155.48 18954 10028 2.0201e+07 5.2 0.12554 5.21 5.25 26925 10032 2.0201e+07 78.21 0.046848 78.21 78.29 28823 10044 2.0201e+07 4.05 -0.051522 4.05 4.1 6071 10051 2.0201e+07 21.99 -0.030851 22.01 22.02 38109 10065 2.0201e+07 17.29 0.036571 17.29 17.3 1.0873e+05
% getting PERMNO where ret > 0:
t{t{:,"ret"} > 0,"PERMNO"}
ans = 4×1
10026 10028 10032 10065

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by