Checks to see if the data structure has a composite question ID variable. If it has none, it checks to see if there are question_id and subquestion variables from which to construct a compqid variable, and proceeds to do so if these are available. Otherwise, the function returns empty. data_st = ensemble_check_compqid(data_st);
0001 function data_st = ensemble_check_compqid(data_st) 0002 % Checks to see if the data structure has a composite question ID variable. 0003 % 0004 % If it has none, it checks to see if there are question_id and subquestion 0005 % variables from which to construct a compqid variable, and proceeds to do so if 0006 % these are available. Otherwise, the function returns empty. 0007 % 0008 % data_st = ensemble_check_compqid(data_st); 0009 % 0010 0011 % 02/06/07 Petr Janata 0012 0013 col = set_var_col_const(data_st.vars); % set the column constants 0014 0015 if isfield(col,'compqid') 0016 return % nothing to construct, so return what we received 0017 end 0018 0019 if ~isfield(col,'compqid') && ~all(isfield(col,{'question_id','subquestion'})) 0020 fprintf(['%s: Did not find necessary question and subquestion or composite question ID' ... 0021 ' information in the input data'], mfilename); 0022 data_st = []; 0023 return 0024 end 0025 0026 % Build the compqid variable if necessary 0027 data_st.vars{end+1} = 'compqid'; 0028 data_st.data{end+1} = make_compqid(data_st.data{col.question_id}, ... 0029 data_st.data{col.subquestion}); 0030 0031 end