Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _processNominals(self, kwargs, data):
nom = kwargs.pop('nominals', None)
inputs = kwargs.pop('input', None)
tgt = kwargs.pop('target', None)
targOpts = kwargs.pop('targOpts', None)
# get char variables and nominals list if it exists
if nom is None:
dsnom = SASProcCommons._charlist(self, data)
elif isinstance(nom, list):
nom = [x.casefold() for x in nom]
dsnom = list(set(SASProcCommons._charlist(self, data)) | set(nom))
else:
raise SyntaxWarning('nominals must be list type. You gave %s.' % str(type(nom)))
if tgt is not None:
# what object type is target
if isinstance(tgt, str):
# if there is special character do nothing
if len([word for word in tgt if any(letter in word for letter in '/\:;.%')]) != 0:
kwargs['target'] = tgt
else:
# turn str into list and search for nominals
tgt_list = tgt.casefold().split()
nom_target = list(set(tgt_list).intersection(dsnom))
int_target = list(set(tgt_list).difference(dsnom))
drop_target = kwargs.pop('target', None)
drop_input = kwargs.pop('input', None)
self.logger.debug(drop_target)
self.logger.debug(drop_input)
elif {'target'}.intersection(required_set) and 'model' in kwargs.keys() and 'target' not in kwargs.keys():
SASProcCommons._convert_model_to_target(self)
verifiedKwargs = SASProcCommons._stmt_check(self, required_set, legal_set, kwargs)
obj1 = []
nosub = False
objname = ''
log = ''
if len(verifiedKwargs):
objname = procname[:3].lower() + self.sas._objcnt() # translate to a libname so needs to be less than 8
code = SASProcCommons._makeProcCallMacro(self, objtype, objname, data, verifiedKwargs)
self.logger.debug(procname + " macro submission: " + str(code))
if not self.sas.nosub:
ll = self.sas.submit(code, "text")
log = ll['LOG']
error = SASProcCommons._errorLog(self, log)
isinstance(error, str)
if len(error) > 1:
RuntimeWarning("ERRORS found in SAS log: \n%s" % error)
return SASresults(obj1, self.sas, objname, nosub, log)
try:
obj1 = SASProcCommons._objectmethods(self, objname)
self.logger.debug(obj1)
except Exception:
pass
else:
print(code)
try:
table = tempdata.split('.')[-1].strip()
lib = tempdata.split('.')[-2]
except IndexError:
lib = ''
# check that the table exists
assert self.sas.exist(table, lib), "The dataset does not exist. Check your spelling and/or libname assignment."
data = self.sas.sasdata(table, lib)
assert isinstance(data, SASdata), "Data must be a sasdata object. Wrong type or string conversion failed."
if required_set is None:
required_set = {}
objtype = procname.lower()
if {'model'}.intersection(required_set) and 'target' in kwargs.keys() and 'model' not in kwargs.keys():
kwargs = SASProcCommons._processNominals(self, kwargs, data)
t_str, tcls_str = SASProcCommons._target_stmt(self, kwargs['target'])
i_str, icls_str = SASProcCommons._input_stmt(self, kwargs['input'])
kwargs['model'] = str(t_str + ' = ' + i_str)
if len(icls_str) > 0:
kwargs['cls'] = str(tcls_str + " " + icls_str)
legal_set.add('cls')
drop_target = kwargs.pop('target', None)
drop_input = kwargs.pop('input', None)
self.logger.debug(drop_target)
self.logger.debug(drop_input)
elif {'target'}.intersection(required_set) and 'model' in kwargs.keys() and 'target' not in kwargs.keys():
SASProcCommons._convert_model_to_target(self)
verifiedKwargs = SASProcCommons._stmt_check(self, required_set, legal_set, kwargs)
obj1 = []
nosub = False
table = tempdata.split('.')[-1].strip()
lib = tempdata.split('.')[-2]
except IndexError:
lib = ''
# check that the table exists
assert self.sas.exist(table, lib), "The dataset does not exist. Check your spelling and/or libname assignment."
data = self.sas.sasdata(table, lib)
assert isinstance(data, SASdata), "Data must be a sasdata object. Wrong type or string conversion failed."
if required_set is None:
required_set = {}
objtype = procname.lower()
if {'model'}.intersection(required_set) and 'target' in kwargs.keys() and 'model' not in kwargs.keys():
kwargs = SASProcCommons._processNominals(self, kwargs, data)
t_str, tcls_str = SASProcCommons._target_stmt(self, kwargs['target'])
i_str, icls_str = SASProcCommons._input_stmt(self, kwargs['input'])
kwargs['model'] = str(t_str + ' = ' + i_str)
if len(icls_str) > 0:
kwargs['cls'] = str(tcls_str + " " + icls_str)
legal_set.add('cls')
drop_target = kwargs.pop('target', None)
drop_input = kwargs.pop('input', None)
self.logger.debug(drop_target)
self.logger.debug(drop_input)
elif {'target'}.intersection(required_set) and 'model' in kwargs.keys() and 'target' not in kwargs.keys():
SASProcCommons._convert_model_to_target(self)
verifiedKwargs = SASProcCommons._stmt_check(self, required_set, legal_set, kwargs)
obj1 = []
nosub = False
objname = ''
objtype = procname.lower()
if {'model'}.intersection(required_set) and 'target' in kwargs.keys() and 'model' not in kwargs.keys():
kwargs = SASProcCommons._processNominals(self, kwargs, data)
t_str, tcls_str = SASProcCommons._target_stmt(self, kwargs['target'])
i_str, icls_str = SASProcCommons._input_stmt(self, kwargs['input'])
kwargs['model'] = str(t_str + ' = ' + i_str)
if len(icls_str) > 0:
kwargs['cls'] = str(tcls_str + " " + icls_str)
legal_set.add('cls')
drop_target = kwargs.pop('target', None)
drop_input = kwargs.pop('input', None)
self.logger.debug(drop_target)
self.logger.debug(drop_input)
elif {'target'}.intersection(required_set) and 'model' in kwargs.keys() and 'target' not in kwargs.keys():
SASProcCommons._convert_model_to_target(self)
verifiedKwargs = SASProcCommons._stmt_check(self, required_set, legal_set, kwargs)
obj1 = []
nosub = False
objname = ''
log = ''
if len(verifiedKwargs):
objname = procname[:3].lower() + self.sas._objcnt() # translate to a libname so needs to be less than 8
code = SASProcCommons._makeProcCallMacro(self, objtype, objname, data, verifiedKwargs)
self.logger.debug(procname + " macro submission: " + str(code))
if not self.sas.nosub:
ll = self.sas.submit(code, "text")
log = ll['LOG']
error = SASProcCommons._errorLog(self, log)
isinstance(error, str)
if len(error) > 1:
elif {'target'}.intersection(required_set) and 'model' in kwargs.keys() and 'target' not in kwargs.keys():
SASProcCommons._convert_model_to_target(self)
verifiedKwargs = SASProcCommons._stmt_check(self, required_set, legal_set, kwargs)
obj1 = []
nosub = False
objname = ''
log = ''
if len(verifiedKwargs):
objname = procname[:3].lower() + self.sas._objcnt() # translate to a libname so needs to be less than 8
code = SASProcCommons._makeProcCallMacro(self, objtype, objname, data, verifiedKwargs)
self.logger.debug(procname + " macro submission: " + str(code))
if not self.sas.nosub:
ll = self.sas.submit(code, "text")
log = ll['LOG']
error = SASProcCommons._errorLog(self, log)
isinstance(error, str)
if len(error) > 1:
RuntimeWarning("ERRORS found in SAS log: \n%s" % error)
return SASresults(obj1, self.sas, objname, nosub, log)
try:
obj1 = SASProcCommons._objectmethods(self, objname)
self.logger.debug(obj1)
except Exception:
pass
else:
print(code)
nosub = True
else:
RuntimeWarning("Error in code submission")
return SASresults(obj1, self.sas, objname, nosub, log)
tempdata = data
try:
table = tempdata.split('.')[-1].strip()
lib = tempdata.split('.')[-2]
except IndexError:
lib = ''
# check that the table exists
assert self.sas.exist(table, lib), "The dataset does not exist. Check your spelling and/or libname assignment."
data = self.sas.sasdata(table, lib)
assert isinstance(data, SASdata), "Data must be a sasdata object. Wrong type or string conversion failed."
if required_set is None:
required_set = {}
objtype = procname.lower()
if {'model'}.intersection(required_set) and 'target' in kwargs.keys() and 'model' not in kwargs.keys():
kwargs = SASProcCommons._processNominals(self, kwargs, data)
t_str, tcls_str = SASProcCommons._target_stmt(self, kwargs['target'])
i_str, icls_str = SASProcCommons._input_stmt(self, kwargs['input'])
kwargs['model'] = str(t_str + ' = ' + i_str)
if len(icls_str) > 0:
kwargs['cls'] = str(tcls_str + " " + icls_str)
legal_set.add('cls')
drop_target = kwargs.pop('target', None)
drop_input = kwargs.pop('input', None)
self.logger.debug(drop_target)
self.logger.debug(drop_input)
elif {'target'}.intersection(required_set) and 'model' in kwargs.keys() and 'target' not in kwargs.keys():
SASProcCommons._convert_model_to_target(self)
verifiedKwargs = SASProcCommons._stmt_check(self, required_set, legal_set, kwargs)
obj1 = []