Why is SAS converting character to numeric? - formatting

I'm build/have built a process for a team in the company I work for. However, I keep seeing this note whenever I run part of my code. SAS Seems to be converting my character values to numeric and it's bugging. It doesn't seem to be causing any apparent issues with my data...but I would like to know why, and solve this issue if I can. here's a snippet of the code from my log:
MPRINT(CFPB): DATA trunc;
MPRINT(CFPB): SET eq_final;
MPRINT(CFPB): Acct_Num=SUBSTR(Acct_Numb,7,4);
MPRINT(CFPB): Source = "Eq";
MPRINT(CFPB): IF Acct_Type = "1" or "01" THEN Acct_Description = "Unsecured";
MPRINT(CFPB): IF Acct_Type = "0" or "00" THEN Acct_Description = "AutoOnly";
MPRINT(CFPB): IF Acct_Type = "2" or "02" THEN Acct_Description = "AutoOther";
MPRINT(CFPB): IF Acct_Type = "6D" THEN Acct_Description = "HELON";
MPRINT(CFPB): IF Acct_Type = "89" THEN Acct_Description = "HELOC";
MPRINT(CFPB): IF Acct_Type = "0G" THEN Acct_Description = "FlexSpending";
MPRINT(CFPB): IF Acct_Type = "18" THEN Acct_Description = "CrCard";
MPRINT(CFPB): IF inputAssocCode not =: "W" AND Error_Description not =: "A1/J1" OR "A2/J2";
MPRINT(CFPB): IF Error_Description not =: "No Error";
MPRINT(CFPB): DROP Acct_Numb ;
MPRINT(CFPB): RUN;
NOTE: Character values have been converted to numeric values at the places given by:
(Line):(Column).
33:113 33:185 34:2 36:118
NOTE: Invalid numeric data, 'A2/J2' , at line 36 column 118.
BASE_CIS_ID=00000123456
Error_Description=A2/J2 Last Name is Missing or Invalid ACCT_Type=6D inputAssocCode=W
Acct_Num=1234 Source=Equifax Acct_Description=HELON _ERROR_=1 _N_=2
NOTE: Invalid numeric data, 'A2/J2' , at line 36 column 118.
BASE_CIS_ID=00000234567 Error_Description=A2/J2 First Name is Missing Invalid
ACCT_Type=00 inputAssocCode=W Acct_Num=2345 Source=Equifax Acct_Description=AutoOther _ERROR_=1
_N_=3

I suspect the issue is with this section of your code and the other similar sections:
IF Acct_Type = "1" or "01" then ...
IF inputAssocCode not =: "W" AND Error_Description not =: "A1/J1" OR "A2/J2";
Due to SAS operator precedence, this is equvalent to:
IF (Acct_Type = "1") or "01" then ...
IF inputAssocCode not =: "W" AND Error_Description (not =: "A1/J1") OR "A2/J2";
SAS will attempt to interpret the character literals "01" and "A2/J2" as logical values because they're being used next to an or operator, which involves converting them to numeric first.
You should use the in operator instead, e.g.
IF Acct_Type in ("1","01") then ...
IF inputAssocCode ne: "W" AND not (Error_Description in: ("A1/J1","A2/J2"));

Related

Python dataframe if if if

Why does my code not run when option2 is 1?
option2 = ""
specificReport = "yes"
if specificReport == "yes":
specificReport = str.lower(input("Do you want to look at the specific report (yes/no) : " ))
option2 = str.lower(input("Which data are you looking for \
(1. Location, 2. Type of Risk, 3. Risk Level , 4. Date & Time): "))
if option2 == 1:
locationValue = input('Enter the location you want to inspect: ')
LocationRow = (dataframe.loc[dataframe['Location Name'] == locationValue])
print(locationRow)
Because the output of input is a string, so you compare option2 (a string) with 1 (an integer). Either you convert the integer to string (i.e., '1' instead of 1) or you convert the output of input to an integer (i.e., int(option2)).
Because it's a string. You need to make it an int
if int(option2) == 1.
Also you don't really need str.lower() on the input - you can make in int() from there too.

String to CRC32 as 4 bytes and LZMA1 conversion in ABAP

I need to for QR code payBySquare in Slovak republic convert Array to string and make CRC32 HASH. Afther that I need comprime HASH by LZMA1 . I hope my code is ok to CRC32 But I cannot find how to make comprimation by LZMA1.
method GENERATE_QR_STRING_FOR_SR.
DATA: lw_string TYPE STRING,
lw_wrbtr_s TYPE STRING,
lo_crc TYPE REF TO IF_SCV_CRC_SERVICES,
lo_crc_hash TYPE REF TO IF_SCV_CRC32.
LW_WRBTR_S = me->WRBTR.
CONCATENATE 'true'
LW_WRBTR_S "
me->WAERS "Currency
'20170101' "'Date'
me->VAR_SYMB "Variabile Symbol
me->CON_SYMB "Constant Symbol
me->SPE_SYMB "Specific Symbol
''
me->INF_FOR_BE "Information for benef..
'1'
me->IBAN "Iban
me->SWIFT "SWIFT
'0'
'0'
INTO lw_string SEPARATED BY ' '.
CONCATENATE '' '1' lw_string INTO lw_string SEPARATED BY ' '.
DATA:
ld_CONTENT TYPE XSTRING ,
ld_CRC32 TYPE I.
" ld_CONTENT = "<Populate with value>
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = LW_STRING
* MIMETYPE = ' '
* ENCODING =
IMPORTING
BUFFER = LD_CONTENT
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL METHOD CL_UJF_ZIP=>CRC32( EXPORTING CONTENT = ld_CONTENT RECEIVING CRC32 = ld_CRC32 ).
"ld_CRC32 = CL_RSBPCF_ZIP=>CRC32( EXPORTING CONTENT = ld_CONTENT ).

Data conversion or data mapping error in SQL

This is my WinSQL query that I try and execute.
SELECT ezait6 AS "MO No",
vhitno AS "Item No",
vhrefd AS "Finish Date",
vhmaqa AS "Manuf Qty",
vhmaun AS "U/M"
FROM m3edbtest.mwohed,
m3edbtest.cinacc
WHERE ezcono = 1
AND vhcono = ezcono
AND vhrefd >= '20170801'
AND vhrefd <= '20170831'
AND vhmfno = ezait6;
--Different Data Types
--vhmfno ==> Integer
--ezait6 ==> nchar(8)
After I run my query, I got below errors:
-- Error : SQL0802 - Data conversion or data mapping error.
I suspect that it is beclose of different data type
I have a nvarchar column in one of my table "ezait6".
So how should I convert that values to INT type.
You can check first if the content of the varchar field is numeric and query only on those:
SELECT ezait6 AS "MO No",
vhitno AS "Item No",
vhrefd AS "Finish Date",
vhmaqa AS "Manuf Qty",
vhmaun AS "U/M"
FROM m3edbtest.mwohed,
m3edbtest.cinacc
WHERE IsNumeric(ezait6)=1
AND ezcono = 1
AND vhcono = ezcono
AND vhrefd >= '20170801'
AND vhrefd <= '20170831'
AND vhmfno = CONVERT(INT,ezait6);

SAP SLT into HANA not updating date field

I would like to SLT data into our HANA Data warehouse. That is the easy part, I can move data that is a one to one match (type 1 table). But I would like to make it type 2 and preserve history. I have the following code in the transform, and it will not populate the update field.
*&---------------------------------------------------------------------*
*& Include ZAUSP_SLT_TRANSFORM
*&---------------------------------------------------------------------*
STATICS lv_syn_name TYPE tabname.
DATA con_name TYPE dbcon_name.
DATA lv_timestamp TYPE timestampl.
FIELD-SYMBOLS <lv_operation> TYPE any.
CONCATENATE _mt_id ':R:R' INTO con_name.
ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <wa_s_AUSP> TO <lv_operation>.
IF sy-subrc = 0 AND
<lv_operation> = 'D'.
IF lv_syn_name IS INITIAL.
CALL METHOD cl_iuuc_tab_ident_access=>get_ident
EXPORTING
iv_mt_id = _mt_id
iv_tabname = _cobj_alias
iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
iv_ident_type = cl_iuuc_tab_ident_access=>co_ident_synonym
IMPORTING
ev_full_name = lv_syn_name.
IF lv_syn_name IS INITIAL.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Get Synonym Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
ENDIF.
GET TIME STAMP FIELD lv_timestamp.
UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
SET ZDELETE_FLAG = 'X'
ZUPD_DATETIME = lv_timestamp
WHERE mandt = <wa_s_AUSP>-mandt
AND objek = <wa_s_AUSP>-objek
AND atinn = <wa_s_AUSP>-atinn
AND atzhl = <wa_s_AUSP>-atzhl
AND mafid = <wa_s_AUSP>-mafid
AND klart = <wa_s_AUSP>-klart
AND adzhl = <wa_s_AUSP>-adzhl.
IF sy-subrc <> 0.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Update Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
skip_record.
ENDIF.
"Code for timestamp outside of delete.
IF lv_syn_name IS INITIAL.
CALL METHOD cl_iuuc_tab_ident_access=>get_ident
EXPORTING
iv_mt_id = _mt_id
iv_tabname = _cobj_alias
iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
iv_ident_type = cl_iuuc_tab_ident_access=>co_ident_synonym
IMPORTING
ev_full_name = lv_syn_name.
IF lv_syn_name IS INITIAL.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Get Synonym Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
ENDIF.
GET TIME STAMP FIELD lv_timestamp.
UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
SET ZUPD_DATETIME = lv_timestamp "slt_update is the name in your slt strucure!
WHERE MANDT = <wa_s_AUSP>-MANDT "key_1 = pk of your table
AND OBJEK = <wa_s_AUSP>-OBJEK
AND ATINN = <wa_s_AUSP>-ATINN
AND ATZHL = <wa_s_AUSP>-ATZHL
AND MAFID = <wa_s_AUSP>-MAFID
AND KLART = <wa_s_AUSP>-KLART
AND ADZHL = <wa_s_AUSP>-ADZHL.
IF sy-subrc <> 0.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Update Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
Why don't the time field get updated for all rows inserted into target? When I try and set a break point to debug during replication, I get the following error:
So I click one, and get the following for each one:
So I go to SE38 and try to activate each one individually:
I did not write the code in these additional programs, and do not understand how they relate to the INCLUDE I wrote. I am left thinking the INCLUDE transform I wrote is not being executed due to the background programs not being active?
The below code resolved my issue.
STATICS lv_syn_name TYPE tabname.
DATA con_name TYPE dbcon_name.
DATA lv_timestamp TYPE timestampl.
FIELD-SYMBOLS <lv_operation> TYPE any.
FIELD-SYMBOLS: <lt_log_tab> TYPE table,
<ls_log_tab> TYPE any,
<lv_primary_key_1> TYPE any,
<lv_primary_key_2> TYPE any,
<lv_primary_key_3> TYPE any,
<lv_primary_key_4> TYPE any.
*
*
*
** get operation flag
ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <wa_s_ausp> TO <lv_operation>.
*
*
IF sy-subrc = 0 AND
<lv_operation> = 'D'.
*
*
**** replication mode and record was deleted
IF lv_syn_name IS INITIAL.
* get synonym name in case of multi use active
CALL METHOD cl_iuuc_tab_ident_access=>get_ident
EXPORTING
iv_mt_id = _mt_id
iv_tabname = _cobj_alias
* iv_tabname = 'AUSP'
iv_system_type = cl_iuuc_tab_ident_access=>co_system_receiver
iv_ident_type = cl_iuuc_tab_ident_access=>co_ident_synonym
IMPORTING
ev_full_name = lv_syn_name.
IF lv_syn_name IS INITIAL.
* set message
allog_msg 'E' 'DMC_RT_MSG' '000'
'Get Synonym Error' space space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
ENDIF.
*
*
*
**** set additional target fields
GET TIME STAMP FIELD lv_timestamp.
CONCATENATE _mt_id ':R:R' INTO con_name.
UPDATE (lv_syn_name) CLIENT SPECIFIED CONNECTION (con_name)
SET deleted = 'X'
delete_time = lv_timestamp
WHERE mandt = <wa_s_ausp>-mandt
AND objek = <wa_s_ausp>-objek
AND atinn = <wa_s_ausp>-atinn
AND atzhl = <wa_s_ausp>-atzhl
AND mafid = <wa_s_ausp>-mafid
AND klart = <wa_s_ausp>-klart
AND adzhl = <wa_s_ausp>-adzhl.
IF sy-subrc <> 0.
DATA(lc_subrc) = sy-subrc.
DATA lc_ausp TYPE c LENGTH 100.
CONCATENATE <wa_s_ausp>-mandt <wa_s_ausp>-objek <wa_s_ausp>-atinn <wa_s_ausp>-atzhl <wa_s_ausp>-mafid <wa_s_ausp>-klart <wa_s_ausp>-adzhl
INTO lc_ausp SEPARATED BY ','.
* set message
allog_msg 'E' 'DMC_RT_MSG' '000'
'Update Error' space space space 'IL '.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Error Details:' lv_syn_name _cobj_alias lc_subrc 'IL '.
allog_msg 'E' 'DMC_RT_MSG' '000'
'Table Details:' lc_ausp space space 'IL '.
RAISE stopped_by_rule.
ENDIF.
**** do not replicate delete
skip_record.
ELSEIF sy-subrc = 0 AND <lv_operation> = 'I'.
GET TIME STAMP FIELD <wa_r_ausp>-insert_time.
ELSEIF sy-subrc = 0 AND <lv_operation> = 'U'.
GET TIME STAMP FIELD <wa_r_ausp>-update_time.
ELSE.
*Initial load branch
GET TIME STAMP FIELD <wa_r_ausp>-insert_time.
ENDIF.

Groovy - The assignment of a string , to a variable of type int results in a number

Assigning empty string or string with letters results in GroovyCastException.Assigning a string with number values results in a number.What operation is happening here?
int var_1 = 2;
println var_1 // 2
var_1 = ""
println var_1 // GroovyCastException
int var_1 = 2;
println var_1 // 2
var_1 = "2"
println var_1 // 50
What operation/s results in 50?
It's considering "2" as a single character string, and assigning that character's Unicode value (U+0032 = '2') to the variable. So for example, I suspect if you do this:
var_1 = "A"
println var_1
you'll see 65 on the console
When you do something like this
var_1 = "2"
println var_1
Then the Unicode value corresponding to the character "2" got printed, which is 50.
Similarly if you will try to print the unicode value of "B" or "C" then you will get 66 or 67 as the results.
You can print a result 50 by doing this:
int var_1 = "2"
println var_1