Need help fixing Vercat error

1 view (last 30 days)
Chris H
Chris H on 9 Oct 2019
Edited: Stephen23 on 9 Oct 2019
load efa_big.mat;
DateStr = datestr('2019-09-04', 'yyyy-mm-dd');
efa = efa_big;
DS_TRADES = ['SELECT DISTINCT '...
'PORTFOLIO, '...
'BUY_SELL_FIX_FLT_NAME, '...
'RUN_DATE, '...
'ISSUER_NAME, '...
'BMK_ISSUER_NAME, '...
'ISSUER_GROUP, '...
'FROM efa '...
'WHERE RUN_DATE(''', DateStr, ''', ''YYYY-MM-DD'') AND '...
'PORTFOLIO = ''Euro Inv'' AND '...
'BUY_SELL_FIX_FLT_NAME = (''Buy'', ''Sell'')'
];
I get the error
"Error using vertcat
Dimensions of arrays being concatenated are not consistent."
What I'm trying to do is in the dataset efa_big I want to pull all the specific column names from line 6-12
DS_TRADES = ['SELECT DISTINCT '...
'PORTFOLIO, '...
'BUY_SELL_FIX_FLT_NAME, '...
'RUN_DATE, '...
'ISSUER_NAME, '...
'BMK_ISSUER_NAME, '...
'ISSUER_GROUP, '...
and filter it for the date range specified, the portfolio name and for all our buys and sells. any idea why I'm getting this error?
'FROM efa '...
'WHERE RUN_DATE(''', DateStr, ''', ''YYYY-MM-DD'') AND '...
'PORTFOLIO = ''Euro Inv'' AND '...
'BUY_SELL_FIX_FLT_NAME = (''Buy'', ''Sell'')'
];
Thanks
  5 Comments
Stephen23
Stephen23 on 9 Oct 2019
Edited: Stephen23 on 9 Oct 2019
"the date in the dataset is numeric so this converts it to an actual date."
That does not explain much, as your code does not use any "datset" as an input to datestr.
What are these lines for? (note that you do not actually use efa anywhere):
load efa_big.mat;
efa = efa_big;
Most likely your DateStr has multiple rows, which will throw that error. But as you provided us with some non-bug-inducing invented data to replace your actual buggy data, we can only guess.
Chris H
Chris H on 9 Oct 2019
Edited: Chris H on 9 Oct 2019
yes there are multiple rows for the date. I copied the full code on the very top. Sorry if that was confusing.
As for the dataset it's pulled from our data warehouse and runs daily. I don't have access to the code that pulls the dataset itself. Formatting sometimes needs to be changed to pull what I'm looking for but it's first time I've gotten this error. Eg. a date that's under the column name run_date will be "735934"
If there are multiple rowns, which there are, do you know how I need to change my code to be able to pull a date range?
load efa_big.mat;
efa = efa_big;
Load efa_big.mat is the actual dataset I'm using
I use efa in the line below
'FROM efa '...
That's where I'm pulling everything I need and trying to filter it since it's a very large dataset.

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 9 Oct 2019
Edited: Stephen23 on 9 Oct 2019
This line will cause an error:
% ' '...
If you want to continue to the next line then you need to use an ellipsis, not %, i.e. this works for me:
... % ellipsis works!
The working file, which runs without error, is attached.
I still don't see the point in datestr('2019-09-04', 'yyyy-mm-dd'), which simply returns the character vector '2019-09-04', so you might as well just define that character vector directly.

More Answers (0)

Categories

Find more on Data Preprocessing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!