BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Malathi13
Obsidian | Level 7

Hi,

I'm trying to convert dates from 20160221 to 02/21/2016 format for a variable "Createdon". I used input and put function together to do it but I'm getting the results with a NOTE:

Mathematical operations could not be performed at the following places. The results of

the operations have been set to missing values.

Each place is given by: (Number of times) at (Line):(Column).

2060 at 198:27

 

the code I used is

data new;

set test;

CREATEDON_0CREATEDON=input(put(CREATEDON_0CREATEDON,z8.),yymmdd8.);

format CREATEDON_0CREATEDON mmddyy10.;

run;

 

I see the output the way I wanted (02/12/2016) but I get that NOTE as well. How can I make sure that I run the programm without any Notes in the log.

 

Thank you

Malathi

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
old_date = ifn(old_date ne ., input(put(old_date, z8.), ?? yymmdd8.), .);

@Malathi13 wrote:

Hi Reeza,

That's the full code and I'm using proc import to import the file with a libname statement. Only issue I have is to get rid of that NOTE in the  log that looks like this:

 

130

131 data n.new;

132 set n.test;

133 CREATEDON_0CREATEDON=input(put(CREATEDON_0CREATEDON,z8.),yymmdd8.);

134 format CREATEDON_0CREATEDON mmddyy10.;

135 *format CREATEDON_0CREATEDON yymmdd10.;

136 if DOC_NUMBER_0DOC_NUMBER eq 'ROW_COUNT' then delete;

137 run;

NOTE: Invalid argument to function INPUT at line 133 column 22.

DOC_NUMBER_0DOC_NUMBER=ROW_COUNT S_ORD_ITEM_0S_ORD_ITEM=2060 SOLD_TO_0SOLD_TO=.

MCK_ID_0CUSTOMER=. CREATEDON_0CREATEDON=. FILE_CRT_DT_0DATE=0 FILE_CRT_TIME_0TIME=0

ORDER_METHOD_ZSPPOTYP= CREATEDBY_0CREATEDBY= REF_ID_0GT_BSTKD= ORD_REASON_0ORD_REASON=

REASON_REJ_0REASON_REJ= MATERIAL_0MATERIAL=. NDC_ZNDCNUMBR=. NDC_DESC_0TXTMD=

ORD_QTY_0CML_OR_QTY=0.000 UOM_0UNIT= FREE_IND_0FLAG= DEL_BLOCK_0DEL_BLOCK=

SHIPTO_STREET_0STREET= SHIPTO_STR_SUPPL1_0STR_SUPPL1= SHIPTO_CITY_0CITY=

SHIPTO_REGION_0REGION= SHIPTO_POSTAL_CD_0POSTAL_CD= SOLDTO_NAME2_0NAME2=

REFER_DOC_0REFER_DOC=. REFER_ITM_0REFER_ITM=0 DOC_TYPE_0DOC_TYPE= ITEM_CATEG_0ITEM_CATEG=

EXT_WAC_0SUBTOTAL_1=0 NET_VAL_0NET_VALUE=0 DISCOUNT_0SUBTOTAL_1=0 DISC_PCT_0SUBTOTAL_1=0

UNIT_WAC_0SUBTOTAL_1=0 SHIP_TO_0SHIP_TO=. SHIP_TO_NAME_0NAME______=,,,,,, _ERROR_=1 _N_=2061

NOTE: Mathematical operations could not be performed at the following places. The results of

the operations have been set to missing values.

Each place is given by: (Number of times) at (Line):(Column).

1 at 133:22

NOTE: There were 2061 observations read from the data set N.TEST.

NOTE: The data set N.NEW has 2060 observations and 36 variables.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.01 seconds

 

Thank you

Malathi


 

Look at the red highlighted portions. It shows that you have missing values and that's causing the issues. You need to add an IF condition to not process the missing values OR use ?? in the INPUT to suppress the errors. 

 

Suppress the notes:

 

old_date = input(put(old_date, z8.), ?? yymmdd8.);

 

 

Avoid calculation:

old_date = ifn(old_date ne ., input(put(old_date, z8.), yymmdd8.), .);

 

View solution in original post

6 REPLIES 6
Reeza
Super User

Please post your full code and log. I cannot replicate your issue, based on the information you've provided. This means it's either something you're not telling us or something else in your code that's causing the issues.

 

data check;
input old_date;
old_date = input(put(old_date, z8.), yymmdd8.);
format old_date date9.;
cards;
20160221
20170105
;
run;

proc print;
run;

Malathi13
Obsidian | Level 7

Hi Reeza,

That's the full code and I'm using proc import to import the file with a libname statement. Only issue I have is to get rid of that NOTE in the  log that looks like this:

 

130

131 data n.new;

132 set n.test;

133 CREATEDON_0CREATEDON=input(put(CREATEDON_0CREATEDON,z8.),yymmdd8.);

134 format CREATEDON_0CREATEDON mmddyy10.;

135 *format CREATEDON_0CREATEDON yymmdd10.;

136 if DOC_NUMBER_0DOC_NUMBER eq 'ROW_COUNT' then delete;

137 run;

NOTE: Invalid argument to function INPUT at line 133 column 22.

DOC_NUMBER_0DOC_NUMBER=ROW_COUNT S_ORD_ITEM_0S_ORD_ITEM=2060 SOLD_TO_0SOLD_TO=.

MCK_ID_0CUSTOMER=. CREATEDON_0CREATEDON=. FILE_CRT_DT_0DATE=0 FILE_CRT_TIME_0TIME=0

ORDER_METHOD_ZSPPOTYP= CREATEDBY_0CREATEDBY= REF_ID_0GT_BSTKD= ORD_REASON_0ORD_REASON=

REASON_REJ_0REASON_REJ= MATERIAL_0MATERIAL=. NDC_ZNDCNUMBR=. NDC_DESC_0TXTMD=

ORD_QTY_0CML_OR_QTY=0.000 UOM_0UNIT= FREE_IND_0FLAG= DEL_BLOCK_0DEL_BLOCK=

SHIPTO_STREET_0STREET= SHIPTO_STR_SUPPL1_0STR_SUPPL1= SHIPTO_CITY_0CITY=

SHIPTO_REGION_0REGION= SHIPTO_POSTAL_CD_0POSTAL_CD= SOLDTO_NAME2_0NAME2=

REFER_DOC_0REFER_DOC=. REFER_ITM_0REFER_ITM=0 DOC_TYPE_0DOC_TYPE= ITEM_CATEG_0ITEM_CATEG=

EXT_WAC_0SUBTOTAL_1=0 NET_VAL_0NET_VALUE=0 DISCOUNT_0SUBTOTAL_1=0 DISC_PCT_0SUBTOTAL_1=0

UNIT_WAC_0SUBTOTAL_1=0 SHIP_TO_0SHIP_TO=. SHIP_TO_NAME_0NAME______=,,,,,, _ERROR_=1 _N_=2061

NOTE: Mathematical operations could not be performed at the following places. The results of

the operations have been set to missing values.

Each place is given by: (Number of times) at (Line):(Column).

1 at 133:22

NOTE: There were 2061 observations read from the data set N.TEST.

NOTE: The data set N.NEW has 2060 observations and 36 variables.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.01 seconds

 

Thank you

Malathi

Reeza
Super User
old_date = ifn(old_date ne ., input(put(old_date, z8.), ?? yymmdd8.), .);

@Malathi13 wrote:

Hi Reeza,

That's the full code and I'm using proc import to import the file with a libname statement. Only issue I have is to get rid of that NOTE in the  log that looks like this:

 

130

131 data n.new;

132 set n.test;

133 CREATEDON_0CREATEDON=input(put(CREATEDON_0CREATEDON,z8.),yymmdd8.);

134 format CREATEDON_0CREATEDON mmddyy10.;

135 *format CREATEDON_0CREATEDON yymmdd10.;

136 if DOC_NUMBER_0DOC_NUMBER eq 'ROW_COUNT' then delete;

137 run;

NOTE: Invalid argument to function INPUT at line 133 column 22.

DOC_NUMBER_0DOC_NUMBER=ROW_COUNT S_ORD_ITEM_0S_ORD_ITEM=2060 SOLD_TO_0SOLD_TO=.

MCK_ID_0CUSTOMER=. CREATEDON_0CREATEDON=. FILE_CRT_DT_0DATE=0 FILE_CRT_TIME_0TIME=0

ORDER_METHOD_ZSPPOTYP= CREATEDBY_0CREATEDBY= REF_ID_0GT_BSTKD= ORD_REASON_0ORD_REASON=

REASON_REJ_0REASON_REJ= MATERIAL_0MATERIAL=. NDC_ZNDCNUMBR=. NDC_DESC_0TXTMD=

ORD_QTY_0CML_OR_QTY=0.000 UOM_0UNIT= FREE_IND_0FLAG= DEL_BLOCK_0DEL_BLOCK=

SHIPTO_STREET_0STREET= SHIPTO_STR_SUPPL1_0STR_SUPPL1= SHIPTO_CITY_0CITY=

SHIPTO_REGION_0REGION= SHIPTO_POSTAL_CD_0POSTAL_CD= SOLDTO_NAME2_0NAME2=

REFER_DOC_0REFER_DOC=. REFER_ITM_0REFER_ITM=0 DOC_TYPE_0DOC_TYPE= ITEM_CATEG_0ITEM_CATEG=

EXT_WAC_0SUBTOTAL_1=0 NET_VAL_0NET_VALUE=0 DISCOUNT_0SUBTOTAL_1=0 DISC_PCT_0SUBTOTAL_1=0

UNIT_WAC_0SUBTOTAL_1=0 SHIP_TO_0SHIP_TO=. SHIP_TO_NAME_0NAME______=,,,,,, _ERROR_=1 _N_=2061

NOTE: Mathematical operations could not be performed at the following places. The results of

the operations have been set to missing values.

Each place is given by: (Number of times) at (Line):(Column).

1 at 133:22

NOTE: There were 2061 observations read from the data set N.TEST.

NOTE: The data set N.NEW has 2060 observations and 36 variables.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.01 seconds

 

Thank you

Malathi


 

Look at the red highlighted portions. It shows that you have missing values and that's causing the issues. You need to add an IF condition to not process the missing values OR use ?? in the INPUT to suppress the errors. 

 

Suppress the notes:

 

old_date = input(put(old_date, z8.), ?? yymmdd8.);

 

 

Avoid calculation:

old_date = ifn(old_date ne ., input(put(old_date, z8.), yymmdd8.), .);

 

Malathi13
Obsidian | Level 7

Hi Reeza,

Thank you so much, when I used ?? in th einput function it worked. Thanks a lot.

 

Malathi

ballardw
Super User

I can recreate a similar message with this code:

data example;
   input CREATEDON_0CREATEDON;
datalines;
20160221
20161131
20161410
0160221
.
999990101
;
run;

data want;
   set example;
   x= CREATEDON_0CREATEDON;
   CREATEDON_0CREATEDON=input(put(CREATEDON_0CREATEDON,z8.),yymmdd8.);
   format CREATEDON_0CREATEDON mmddyy10.;
run;

But you may want to pay attention to more of the log:

 

NOTE: Invalid argument to function INPUT at line 856 column 25.
CREATEDON_0CREATEDON=. x=20161131 _ERROR_=1 _N_=2
NOTE: Invalid argument to function INPUT at line 856 column 25.
CREATEDON_0CREATEDON=. x=20161410 _ERROR_=1 _N_=3
NOTE: Invalid argument to function INPUT at line 856 column 25.
CREATEDON_0CREATEDON=. x=999990101 _ERROR_=1 _N_=6
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      3 at 856:25

Any value that cannot be considered a valid date will generate that error.

 

I do not understand the use of the Z8 format. If you have a value that does not have 8 digits then you have moved the value to a year prior to 1585 and the SAS data conversions do not go that far back and can generate that error. You would be better off checking the range of the value and if it is less than something reasonable for your project such as 19000101 then treat that differently. You may need to parse to get year/month/day and supply an assumed date or use a different infomat. If you want 201601, without a day of month, to be treated as jan 1, 2016 then you may want to attempt to read with a yymm6. format which assumes the day is 01.

Kurt_Bremser
Super User

Don't nest the function calls. Create a new character variable with put(...,z8.) and use that in the input(...,yymmdd8.). That way you can see in the log which value causes the problem. Drop the intermediate variable if you don't want it in the dataset.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2602 views
  • 1 like
  • 4 in conversation