def is_print_statement(i): if type(i) == sasoptpy.abstract.PrintStatement: return True elif isinstance(i, sasoptpy.abstract.Statement): if 'print' in sasoptpy.to_definition(i)[:5]: return True return False
def is_solve_statement(i): if type(i) == sasoptpy.abstract.SolveStatement: return True elif isinstance(i, sasoptpy.abstract.Statement): if 'solve' in sasoptpy.to_definition(i)[:5]: return True return False
def _expr(self): member_defs = ', '.join(sasoptpy.to_definition(i) for i in self.elements) conditions = self.sym.get_conditions_str() if conditions != '': return f'{{{member_defs}: {conditions}}}' else: return f'{{{member_defs}}}'
def get_column_str(cls, c): target = c.get('target') column = c.get('column') index = c.get('index') target_str = '' connect_str = '' column_str = '' if target: target_str += '{}'.format(ReadDataStatement.get_target_expr(target)) if target and column: connect_str += '=' if column: if sasoptpy.util.has_expr(column): column_str += 'col(' + column._expr() + ')' else: column_str += '{}'.format(column) # If both equal, no need for second part if target_str == column_str: connect_str = '' column_str = '' s = target_str + connect_str + column_str if index and sasoptpy.abstract.util.is_key_abstract(index): s = '{{{}}} < {} >'.format(sasoptpy.to_definition(index), s) return s
def _defn(self): s = self.keyword + ' ' if self.condition: s += self.condition._expr() + ' ' s += self.get_do_word() + ';\n' eldefs = [] for i in self.elements: eldef = sasoptpy.to_definition(i) if eldef is not None: eldefs.append(eldef) s += sasoptpy.util.addSpaces('\n'.join(eldefs), 3) + '\n' s += 'end;' return s
def _defn(self): s = f'{self.keyword} ' s += '{' loops = [] for i, it in enumerate(self.iterators): loops.append('{} in {}'.format( sasoptpy.util.package_utils._to_sas_string(it), sasoptpy.util.package_utils._to_sas_string( self._sets[i]) #._expr() )) s += ', '.join(loops) s += '} do;\n' eldefs = [] for i in self.elements: eldef = sasoptpy.to_definition(i) if eldef is not None: eldefs.append(eldef) s += sasoptpy.util.addSpaces('\n'.join(eldefs), 3) + '\n' s += 'end;' return s
def get_column_str(cls, c): name = c.get('name') expr = c.get('expression', c.get('expr')) index = c.get('index') if not isinstance(index, list): index = [index] name_str = '' connect_str = '' expr_str = '' if name: if hasattr(name, '_expr'): name_str = 'col(' + name._expr() + ')' else: name_str = str(name) if name and expr: connect_str += '=' if expr: if sasoptpy.util.has_expr(expr): expr_str += expr._expr() else: expr_str += '{}'.format(expr) if name_str == expr_str: connect_str = '' expr_str = '' if name_str != '': expr_str = '({})'.format(expr_str) s = name_str + connect_str + expr_str if index and any( sasoptpy.abstract.util.is_key_abstract(i) for i in index): index_str = ', '.join([sasoptpy.to_definition(i) for i in index]) s = '{{{}}} < {} >'.format(index_str, s) return s
def _defn(self): eldefs = [] for i in self.elements: eldefs.append(sasoptpy.to_definition(i)) return '\n'.join(eldefs)