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

I need to convert a range of variables having format dollar12. with num type, to comma12. into a new variable. I'm able to do it with input function but not with put function. Below is the code I'm using for the conversion. 

Also, here input is not converting the data type num to char as it supposed to. Can Anyone explain

 

data a;
set sasuser.Quarter2;
array k(5) CrgoRev1-CrgoRev5;
array r(5) r1-r5;
array z(5) z1-z5;
do i=1 to 5;
r(i)=input(k(i),comma14.);        /* this is working*/
z(i)=put(r(i),dollar14.);             /* this is giving error*/
end;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15
data want;
set have;
array k(5) $ CrgoRev1-CrgoRev5; /* dollar $ was missing */
array r(5) r1-r5;
array z(5) $ 14 z1-z5; /* dollar $ was missing, and the length  */
do i=1 to 5;
  r(i)=input(k(i),comma14.);   
  z(i)=put(r(i), dollar14.);    
end;
run;

and if your "have" data looks like this:

data have;
array x[*] $ 20 CrgoRev1-CrgoRev5
(
"'    $3,360,224'"
"'      $560,116'"
"'    $2,361,846'"
"'    $1,845,832'"
"'      $222,980'"
)
;
run;

you should also use:

r(i)=input(DEQUOTE(k(i)),comma14.); 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

14 REPLIES 14
PaigeMiller
Diamond | Level 26

In general, it is not sufficient to say something isn't working. You need to show us the LOG for this section of code, without chopping anything out; we need to see the code as it appears in the LOG, we need to see all the NOTEs and WARNINGs and ERRORs as reported in the LOG. Show the LOG to us by clicking on the </> icon and pasting (as text) the log into the window that appears. DO NOT SKIP THIS STEP.

--
Paige Miller
andreas_lds
Jade | Level 19
Start by reading the docs of put & input. Afaik input always returns a numeric value, while put always returns an alphanumeric value. Second step: read the log and post it here if you have questions, but please post the log as whole using the </> button.
Tom
Super User Tom
Super User

@andreas_lds wrote:
Start by reading the docs of put & input. Afaik input always returns a numeric value, while put always returns an alphanumeric value. Second step: read the log and post it here if you have questions, but please post the log as whole using the </> button.

Not quite.  PUT() always generates TEXT from VALUES and INPUT() always generates VALUES from TEXT.  But whether the value is numeric or character is determined by the type of INFORMAT used.  Numeric values need numeric formats/informats.  Character values need character formats/informats.

andreas_lds
Jade | Level 19
Thanks @Tom.
krishnaarrora
Calcite | Level 5

If I run the below code, I'm getting the desires output but in the logs, it states that " Numeric values have been converted to character values". But when I dug into the column's properties, the new variables r1-r5 are still of numeric type.

data a;
set sasuser.Quarter2;
array k(5) CrgoRev1-CrgoRev5;
array r(5) r1-r5;
array z(5) z1-z5;
do i=1 to 5;
r(i)=input(k(i),comma14.); /* this is working*/
end;
run;

 

PaigeMiller
Diamond | Level 26

Can you please show us the entire LOG for this section of code, as requested earlier, by following the instructions exactly?

 

You need to show us the LOG for this section of code, without chopping anything out; we need to see the code as it appears in the LOG, we need to see all the NOTEs and WARNINGs and ERRORs as reported in the LOG. Show the LOG to us by clicking on the </> icon and pasting (as text) the log into the window that appears. DO NOT SKIP THIS STEP.

 

 

--
Paige Miller
krishnaarrora
Calcite | Level 5

I've attached the log for the above code 

404  data a;
405  set sasuser.Quarter2;
406  array k(5) CrgoRev1-CrgoRev5;
407  array r(5) r1-r5;
408  array z(5) z1-z5;
409  do i=1 to 5;
410  r(i)=input(k(i),comma14.);        /* this is working*/
411  z(i)=put(r(i),dollar14.);             /* this is giving error*/
412  end;
413  run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      410:12
NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      411:1
NOTE: Invalid numeric data, '    $3,360,224' , at line 411 column 6.
NOTE: Invalid numeric data, '      $560,116' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,361,846' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,845,832' , at line 411 column 6.
NOTE: Invalid numeric data, '      $222,980' , at line 411 column 6.
Date=01APR2000 CrgoRev1=$3,360,224 CrgoRev2=$560,116 CrgoRev3=$2,361,846
CrgoRev4=$1,845,832 CrgoRev5=$222,980 CrgoRev6=$950,321 comment=Lots of Cargo/Heavy Load
r1=3360224 r2=560116 r3=2361846 r4=1845832 r5=222980 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=1
NOTE: Invalid numeric data, '    $3,222,492' , at line 411 column 6.
NOTE: Invalid numeric data, '      $571,166' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,140,953' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,801,966' , at line 411 column 6.
NOTE: Invalid numeric data, '      $225,088' , at line 411 column 6.
Date=02APR2000 CrgoRev1=$3,222,492 CrgoRev2=$571,166 CrgoRev3=$2,140,953
CrgoRev4=$1,801,966 CrgoRev5=$225,088 CrgoRev6=$980,593 comment=Medium Filled r1=3222492
r2=571166 r3=2140953 r4=1801966 r5=225088 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=2
NOTE: Invalid numeric data, '    $3,290,158' , at line 411 column 6.
NOTE: Invalid numeric data, '      $562,068' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,893,226' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,828,742' , at line 411 column 6.
NOTE: Invalid numeric data, '      $219,478' , at line 411 column 6.
Date=03APR2000 CrgoRev1=$3,290,158 CrgoRev2=$562,068 CrgoRev3=$1,893,226
CrgoRev4=$1,828,742 CrgoRev5=$219,478 CrgoRev6=$961,781 comment=Light Load r1=3290158
r2=562068 r3=1893226 r4=1828742 r5=219478 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=3
NOTE: Invalid numeric data, '    $3,329,256' , at line 411 column 6.
NOTE: Invalid numeric data, '      $550,838' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,156,947' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,818,490' , at line 411 column 6.
NOTE: Invalid numeric data, '      $231,204' , at line 411 column 6.
Date=04APR2000 CrgoRev1=$3,329,256 CrgoRev2=$550,838 CrgoRev3=$2,156,947
CrgoRev4=$1,818,490 CrgoRev5=$231,204 CrgoRev6=$990,915 comment=Lots of Cargo/Heavy Load
r1=3329256 r2=550838 r3=2156947 r4=1818490 r5=231204 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=4
NOTE: Invalid numeric data, '    $3,303,818' , at line 411 column 6.
NOTE: Invalid numeric data, '      $535,984' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,364,056' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,849,634' , at line 411 column 6.
NOTE: Invalid numeric data, '      $228,828' , at line 411 column 6.
Date=05APR2000 CrgoRev1=$3,303,818 CrgoRev2=$535,984 CrgoRev3=$2,364,056
CrgoRev4=$1,849,634 CrgoRev5=$228,828 CrgoRev6=$987,061 comment=Lots of Cargo/Heavy Load
r1=3303818 r2=535984 r3=2364056 r4=1849634 r5=228828 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=5
NOTE: Invalid numeric data, '    $3,343,278' , at line 411 column 6.
NOTE: Invalid numeric data, '      $578,444' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,113,087' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,851,190' , at line 411 column 6.
NOTE: Invalid numeric data, '      $216,468' , at line 411 column 6.
Date=06APR2000 CrgoRev1=$3,343,278 CrgoRev2=$578,444 CrgoRev3=$2,113,087
CrgoRev4=$1,851,190 CrgoRev5=$216,468 CrgoRev6=$962,811 comment=Lots of Cargo/Heavy Load
r1=3343278 r2=578444 r3=2113087 r4=1851190 r5=216468 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=6
NOTE: Invalid numeric data, '    $3,307,558' , at line 411 column 6.
NOTE: Invalid numeric data, '      $530,094' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,130,893' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,799,830' , at line 411 column 6.
NOTE: Invalid numeric data, '      $218,580' , at line 411 column 6.
Date=07APR2000 CrgoRev1=$3,307,558 CrgoRev2=$530,094 CrgoRev3=$2,130,893
CrgoRev4=$1,799,830 CrgoRev5=$218,580 CrgoRev6=$1,190,912 comment=Lots of Cargo/Heavy Load
r1=3307558 r2=530094 r3=2130893 r4=1799830 r5=218580 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=7
NOTE: Invalid numeric data, '    $3,294,386' , at line 411 column 6.
NOTE: Invalid numeric data, '      $546,394' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,324,474' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,794,090' , at line 411 column 6.
NOTE: Invalid numeric data, '      $215,946' , at line 411 column 6.
Date=08APR2000 CrgoRev1=$3,294,386 CrgoRev2=$546,394 CrgoRev3=$2,324,474
CrgoRev4=$1,794,090 CrgoRev5=$215,946 CrgoRev6=$983,759 comment=Lots of Cargo/Heavy Load
r1=3294386 r2=546394 r3=2324474 r4=1794090 r5=215946 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=8
NOTE: Invalid numeric data, '    $3,312,514' , at line 411 column 6.
NOTE: Invalid numeric data, '      $566,612' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,124,797' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,786,608' , at line 411 column 6.
NOTE: Invalid numeric data, '      $224,168' , at line 411 column 6.
Date=09APR2000 CrgoRev1=$3,312,514 CrgoRev2=$566,612 CrgoRev3=$2,124,797
CrgoRev4=$1,786,608 CrgoRev5=$224,168 CrgoRev6=$983,065 comment=Medium Filled r1=3312514
r2=566612 r3=2124797 r4=1786608 r5=224168 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=9
NOTE: Invalid numeric data, '    $3,334,438' , at line 411 column 6.
NOTE: Invalid numeric data, '      $558,276' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,916,504' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,740,686' , at line 411 column 6.
NOTE: Invalid numeric data, '      $220,564' , at line 411 column 6.
Date=10APR2000 CrgoRev1=$3,334,438 CrgoRev2=$558,276 CrgoRev3=$1,916,504
CrgoRev4=$1,740,686 CrgoRev5=$220,564 CrgoRev6=$980,903 comment=Light Load r1=3334438
r2=558276 r3=1916504 r4=1740686 r5=220564 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=10
NOTE: Invalid numeric data, '    $3,246,212' , at line 411 column 6.
NOTE: Invalid numeric data, '      $554,160' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,115,663' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,835,040' , at line 411 column 6.
NOTE: Invalid numeric data, '      $220,414' , at line 411 column 6.
Date=11APR2000 CrgoRev1=$3,246,212 CrgoRev2=$554,160 CrgoRev3=$2,115,663
CrgoRev4=$1,835,040 CrgoRev5=$220,414 CrgoRev6=$942,427 comment=Medium Filled r1=3246212
r2=554160 r3=2115663 r4=1835040 r5=220414 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=11
NOTE: Invalid numeric data, '    $3,299,584' , at line 411 column 6.
NOTE: Invalid numeric data, '      $559,020' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,324,546' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,826,890' , at line 411 column 6.
NOTE: Invalid numeric data, '      $218,514' , at line 411 column 6.
Date=12APR2000 CrgoRev1=$3,299,584 CrgoRev2=$559,020 CrgoRev3=$2,324,546
CrgoRev4=$1,826,890 CrgoRev5=$218,514 CrgoRev6=$990,955 comment=Lots of Cargo/Heavy Load
r1=3299584 r2=559020 r3=2324546 r4=1826890 r5=218514 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=12
NOTE: Invalid numeric data, '    $3,233,178' , at line 411 column 6.
NOTE: Invalid numeric data, '      $568,428' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,145,419' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,819,352' , at line 411 column 6.
NOTE: Invalid numeric data, '      $229,708' , at line 411 column 6.
Date=13APR2000 CrgoRev1=$3,233,178 CrgoRev2=$568,428 CrgoRev3=$2,145,419
CrgoRev4=$1,819,352 CrgoRev5=$229,708 CrgoRev6=$973,789 comment=Medium Filled r1=3233178
r2=568428 r3=2145419 r4=1819352 r5=229708 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=13
NOTE: Invalid numeric data, '    $3,339,964' , at line 411 column 6.
NOTE: Invalid numeric data, '      $546,348' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,133,755' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,816,434' , at line 411 column 6.
NOTE: Invalid numeric data, '      $235,424' , at line 411 column 6.
Date=14APR2000 CrgoRev1=$3,339,964 CrgoRev2=$546,348 CrgoRev3=$2,133,755
CrgoRev4=$1,816,434 CrgoRev5=$235,424 CrgoRev6=$1,241,964 comment=Lots of Cargo/Heavy Load
r1=3339964 r2=546348 r3=2133755 r4=1816434 r5=235424 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=14
NOTE: Invalid numeric data, '    $3,275,138' , at line 411 column 6.
NOTE: Invalid numeric data, '      $578,946' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,358,002' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,842,628' , at line 411 column 6.
NOTE: Invalid numeric data, '      $226,276' , at line 411 column 6.
Date=15APR2000 CrgoRev1=$3,275,138 CrgoRev2=$578,946 CrgoRev3=$2,358,002
CrgoRev4=$1,842,628 CrgoRev5=$226,276 CrgoRev6=$981,989 comment=Lots of Cargo/Heavy Load
r1=3275138 r2=578946 r3=2358002 r4=1842628 r5=226276 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=15
NOTE: Invalid numeric data, '    $3,341,368' , at line 411 column 6.
NOTE: Invalid numeric data, '      $536,186' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,140,997' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,852,846' , at line 411 column 6.
NOTE: Invalid numeric data, '      $220,084' , at line 411 column 6.
Date=16APR2000 CrgoRev1=$3,341,368 CrgoRev2=$536,186 CrgoRev3=$2,140,997
CrgoRev4=$1,852,846 CrgoRev5=$220,084 CrgoRev6=$959,279 comment=Lots of Cargo/Heavy Load
r1=3341368 r2=536186 r3=2140997 r4=1852846 r5=220084 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=16
NOTE: Invalid numeric data, '    $3,324,722' , at line 411 column 6.
NOTE: Invalid numeric data, '      $551,820' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,908,640' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,825,610' , at line 411 column 6.
NOTE: Invalid numeric data, '      $223,868' , at line 411 column 6.
Date=17APR2000 CrgoRev1=$3,324,722 CrgoRev2=$551,820 CrgoRev3=$1,908,640
CrgoRev4=$1,825,610 CrgoRev5=$223,868 CrgoRev6=$1,012,759 comment=Medium Filled r1=3324722
r2=551820 r3=1908640 r4=1825610 r5=223868 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=17
NOTE: Invalid numeric data, '    $3,275,894' , at line 411 column 6.
NOTE: Invalid numeric data, '      $544,790' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,135,871' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,802,274' , at line 411 column 6.
NOTE: Invalid numeric data, '      $221,208' , at line 411 column 6.
Date=18APR2000 CrgoRev1=$3,275,894 CrgoRev2=$544,790 CrgoRev3=$2,135,871
CrgoRev4=$1,802,274 CrgoRev5=$221,208 CrgoRev6=$949,587 comment=Medium Filled r1=3275894
r2=544790 r3=2135871 r4=1802274 r5=221208 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=18
NOTE: Invalid numeric data, '    $3,264,274' , at line 411 column 6.
NOTE: Invalid numeric data, '      $558,732' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,387,136' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,824,802' , at line 411 column 6.
NOTE: Invalid numeric data, '      $212,922' , at line 411 column 6.
Date=19APR2000 CrgoRev1=$3,264,274 CrgoRev2=$558,732 CrgoRev3=$2,387,136
CrgoRev4=$1,824,802 CrgoRev5=$212,922 CrgoRev6=$980,465 comment=Lots of Cargo/Heavy Load
r1=3264274 r2=558732 r3=2387136 r4=1824802 r5=212922 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=19
NOTE: Invalid numeric data, '    $3,295,010' , at line 411 column 6.
NOTE: Invalid numeric data, '      $556,194' , at line 411 column 6.
NOTE: Invalid numeric data, '    $2,136,315' , at line 411 column 6.
NOTE: Invalid numeric data, '    $1,813,862' , at line 411 column 6.
NOTE: Invalid numeric data, '      $223,224' , at line 411 column 6.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be
         printed.
Date=20APR2000 CrgoRev1=$3,295,010 CrgoRev2=$556,194 CrgoRev3=$2,136,315
CrgoRev4=$1,813,862 CrgoRev5=$223,224 CrgoRev6=$972,671 comment=Medium Filled r1=3295010
r2=556194 r3=2136315 r4=1813862 r5=223224 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=20
NOTE: There were 50 observations read from the data set SASUSER.QUARTER2.
NOTE: The data set WORK.A has 50 observations and 19 variables.
NOTE: DATA statement used (Total process time):
      real time           0.52 seconds
      cpu time            0.37 seconds


414  data a;
415  set sasuser.Quarter2;
416  array k(5) CrgoRev1-CrgoRev5;
417  array r(5) r1-r5;
418  array z(5) z1-z5;
419  do i=1 to 5;
420  r(i)=input(k(i),comma14.);        /* this is working*/
421  end;
422  run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      420:12
NOTE: There were 50 observations read from the data set SASUSER.QUARTER2.
NOTE: The data set WORK.A has 50 observations and 19 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.04 seconds


423  data a;
424  set sasuser.Quarter2;
425  array k(5) CrgoRev1-CrgoRev5;
426  array r(5) r1-r5;
427  array z(5) z1-z5;
428  do i=1 to 5;
429  r(i)=input(k(i),comma14.);
430  z(i)=put(k(i),comma14.);
431  end;
432  run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      429:12
NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      430:1
NOTE: Invalid numeric data, '     3,360,224' , at line 430 column 6.
NOTE: Invalid numeric data, '       560,116' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,361,846' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,845,832' , at line 430 column 6.
NOTE: Invalid numeric data, '       222,980' , at line 430 column 6.
Date=01APR2000 CrgoRev1=$3,360,224 CrgoRev2=$560,116 CrgoRev3=$2,361,846
CrgoRev4=$1,845,832 CrgoRev5=$222,980 CrgoRev6=$950,321 comment=Lots of Cargo/Heavy Load
r1=3360224 r2=560116 r3=2361846 r4=1845832 r5=222980 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=1
NOTE: Invalid numeric data, '     3,222,492' , at line 430 column 6.
NOTE: Invalid numeric data, '       571,166' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,140,953' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,801,966' , at line 430 column 6.
NOTE: Invalid numeric data, '       225,088' , at line 430 column 6.
Date=02APR2000 CrgoRev1=$3,222,492 CrgoRev2=$571,166 CrgoRev3=$2,140,953
CrgoRev4=$1,801,966 CrgoRev5=$225,088 CrgoRev6=$980,593 comment=Medium Filled r1=3222492
r2=571166 r3=2140953 r4=1801966 r5=225088 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=2
NOTE: Invalid numeric data, '     3,290,158' , at line 430 column 6.
NOTE: Invalid numeric data, '       562,068' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,893,226' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,828,742' , at line 430 column 6.
NOTE: Invalid numeric data, '       219,478' , at line 430 column 6.
Date=03APR2000 CrgoRev1=$3,290,158 CrgoRev2=$562,068 CrgoRev3=$1,893,226
CrgoRev4=$1,828,742 CrgoRev5=$219,478 CrgoRev6=$961,781 comment=Light Load r1=3290158
r2=562068 r3=1893226 r4=1828742 r5=219478 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=3
NOTE: Invalid numeric data, '     3,329,256' , at line 430 column 6.
NOTE: Invalid numeric data, '       550,838' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,156,947' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,818,490' , at line 430 column 6.
NOTE: Invalid numeric data, '       231,204' , at line 430 column 6.
Date=04APR2000 CrgoRev1=$3,329,256 CrgoRev2=$550,838 CrgoRev3=$2,156,947
CrgoRev4=$1,818,490 CrgoRev5=$231,204 CrgoRev6=$990,915 comment=Lots of Cargo/Heavy Load
r1=3329256 r2=550838 r3=2156947 r4=1818490 r5=231204 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=4
NOTE: Invalid numeric data, '     3,303,818' , at line 430 column 6.
NOTE: Invalid numeric data, '       535,984' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,364,056' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,849,634' , at line 430 column 6.
NOTE: Invalid numeric data, '       228,828' , at line 430 column 6.
Date=05APR2000 CrgoRev1=$3,303,818 CrgoRev2=$535,984 CrgoRev3=$2,364,056
CrgoRev4=$1,849,634 CrgoRev5=$228,828 CrgoRev6=$987,061 comment=Lots of Cargo/Heavy Load
r1=3303818 r2=535984 r3=2364056 r4=1849634 r5=228828 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=5
NOTE: Invalid numeric data, '     3,343,278' , at line 430 column 6.
NOTE: Invalid numeric data, '       578,444' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,113,087' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,851,190' , at line 430 column 6.
NOTE: Invalid numeric data, '       216,468' , at line 430 column 6.
Date=06APR2000 CrgoRev1=$3,343,278 CrgoRev2=$578,444 CrgoRev3=$2,113,087
CrgoRev4=$1,851,190 CrgoRev5=$216,468 CrgoRev6=$962,811 comment=Lots of Cargo/Heavy Load
r1=3343278 r2=578444 r3=2113087 r4=1851190 r5=216468 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=6
NOTE: Invalid numeric data, '     3,307,558' , at line 430 column 6.
NOTE: Invalid numeric data, '       530,094' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,130,893' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,799,830' , at line 430 column 6.
NOTE: Invalid numeric data, '       218,580' , at line 430 column 6.
Date=07APR2000 CrgoRev1=$3,307,558 CrgoRev2=$530,094 CrgoRev3=$2,130,893
CrgoRev4=$1,799,830 CrgoRev5=$218,580 CrgoRev6=$1,190,912 comment=Lots of Cargo/Heavy Load
r1=3307558 r2=530094 r3=2130893 r4=1799830 r5=218580 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=7
NOTE: Invalid numeric data, '     3,294,386' , at line 430 column 6.
NOTE: Invalid numeric data, '       546,394' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,324,474' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,794,090' , at line 430 column 6.
NOTE: Invalid numeric data, '       215,946' , at line 430 column 6.
Date=08APR2000 CrgoRev1=$3,294,386 CrgoRev2=$546,394 CrgoRev3=$2,324,474
CrgoRev4=$1,794,090 CrgoRev5=$215,946 CrgoRev6=$983,759 comment=Lots of Cargo/Heavy Load
r1=3294386 r2=546394 r3=2324474 r4=1794090 r5=215946 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=8
NOTE: Invalid numeric data, '     3,312,514' , at line 430 column 6.
NOTE: Invalid numeric data, '       566,612' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,124,797' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,786,608' , at line 430 column 6.
NOTE: Invalid numeric data, '       224,168' , at line 430 column 6.
Date=09APR2000 CrgoRev1=$3,312,514 CrgoRev2=$566,612 CrgoRev3=$2,124,797
CrgoRev4=$1,786,608 CrgoRev5=$224,168 CrgoRev6=$983,065 comment=Medium Filled r1=3312514
r2=566612 r3=2124797 r4=1786608 r5=224168 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=9
NOTE: Invalid numeric data, '     3,334,438' , at line 430 column 6.
NOTE: Invalid numeric data, '       558,276' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,916,504' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,740,686' , at line 430 column 6.
NOTE: Invalid numeric data, '       220,564' , at line 430 column 6.
Date=10APR2000 CrgoRev1=$3,334,438 CrgoRev2=$558,276 CrgoRev3=$1,916,504
CrgoRev4=$1,740,686 CrgoRev5=$220,564 CrgoRev6=$980,903 comment=Light Load r1=3334438
r2=558276 r3=1916504 r4=1740686 r5=220564 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=10
NOTE: Invalid numeric data, '     3,246,212' , at line 430 column 6.
NOTE: Invalid numeric data, '       554,160' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,115,663' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,835,040' , at line 430 column 6.
NOTE: Invalid numeric data, '       220,414' , at line 430 column 6.
Date=11APR2000 CrgoRev1=$3,246,212 CrgoRev2=$554,160 CrgoRev3=$2,115,663
CrgoRev4=$1,835,040 CrgoRev5=$220,414 CrgoRev6=$942,427 comment=Medium Filled r1=3246212
r2=554160 r3=2115663 r4=1835040 r5=220414 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=11
NOTE: Invalid numeric data, '     3,299,584' , at line 430 column 6.
NOTE: Invalid numeric data, '       559,020' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,324,546' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,826,890' , at line 430 column 6.
NOTE: Invalid numeric data, '       218,514' , at line 430 column 6.
Date=12APR2000 CrgoRev1=$3,299,584 CrgoRev2=$559,020 CrgoRev3=$2,324,546
CrgoRev4=$1,826,890 CrgoRev5=$218,514 CrgoRev6=$990,955 comment=Lots of Cargo/Heavy Load
r1=3299584 r2=559020 r3=2324546 r4=1826890 r5=218514 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=12
NOTE: Invalid numeric data, '     3,233,178' , at line 430 column 6.
NOTE: Invalid numeric data, '       568,428' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,145,419' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,819,352' , at line 430 column 6.
NOTE: Invalid numeric data, '       229,708' , at line 430 column 6.
Date=13APR2000 CrgoRev1=$3,233,178 CrgoRev2=$568,428 CrgoRev3=$2,145,419
CrgoRev4=$1,819,352 CrgoRev5=$229,708 CrgoRev6=$973,789 comment=Medium Filled r1=3233178
r2=568428 r3=2145419 r4=1819352 r5=229708 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=13
NOTE: Invalid numeric data, '     3,339,964' , at line 430 column 6.
NOTE: Invalid numeric data, '       546,348' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,133,755' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,816,434' , at line 430 column 6.
NOTE: Invalid numeric data, '       235,424' , at line 430 column 6.
Date=14APR2000 CrgoRev1=$3,339,964 CrgoRev2=$546,348 CrgoRev3=$2,133,755
CrgoRev4=$1,816,434 CrgoRev5=$235,424 CrgoRev6=$1,241,964 comment=Lots of Cargo/Heavy Load
r1=3339964 r2=546348 r3=2133755 r4=1816434 r5=235424 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=14
NOTE: Invalid numeric data, '     3,275,138' , at line 430 column 6.
NOTE: Invalid numeric data, '       578,946' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,358,002' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,842,628' , at line 430 column 6.
NOTE: Invalid numeric data, '       226,276' , at line 430 column 6.
Date=15APR2000 CrgoRev1=$3,275,138 CrgoRev2=$578,946 CrgoRev3=$2,358,002
CrgoRev4=$1,842,628 CrgoRev5=$226,276 CrgoRev6=$981,989 comment=Lots of Cargo/Heavy Load
r1=3275138 r2=578946 r3=2358002 r4=1842628 r5=226276 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=15
NOTE: Invalid numeric data, '     3,341,368' , at line 430 column 6.
NOTE: Invalid numeric data, '       536,186' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,140,997' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,852,846' , at line 430 column 6.
NOTE: Invalid numeric data, '       220,084' , at line 430 column 6.
Date=16APR2000 CrgoRev1=$3,341,368 CrgoRev2=$536,186 CrgoRev3=$2,140,997
CrgoRev4=$1,852,846 CrgoRev5=$220,084 CrgoRev6=$959,279 comment=Lots of Cargo/Heavy Load
r1=3341368 r2=536186 r3=2140997 r4=1852846 r5=220084 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=16
NOTE: Invalid numeric data, '     3,324,722' , at line 430 column 6.
NOTE: Invalid numeric data, '       551,820' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,908,640' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,825,610' , at line 430 column 6.
NOTE: Invalid numeric data, '       223,868' , at line 430 column 6.
Date=17APR2000 CrgoRev1=$3,324,722 CrgoRev2=$551,820 CrgoRev3=$1,908,640
CrgoRev4=$1,825,610 CrgoRev5=$223,868 CrgoRev6=$1,012,759 comment=Medium Filled r1=3324722
r2=551820 r3=1908640 r4=1825610 r5=223868 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=17
NOTE: Invalid numeric data, '     3,275,894' , at line 430 column 6.
NOTE: Invalid numeric data, '       544,790' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,135,871' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,802,274' , at line 430 column 6.
NOTE: Invalid numeric data, '       221,208' , at line 430 column 6.
Date=18APR2000 CrgoRev1=$3,275,894 CrgoRev2=$544,790 CrgoRev3=$2,135,871
CrgoRev4=$1,802,274 CrgoRev5=$221,208 CrgoRev6=$949,587 comment=Medium Filled r1=3275894
r2=544790 r3=2135871 r4=1802274 r5=221208 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=18
NOTE: Invalid numeric data, '     3,264,274' , at line 430 column 6.
NOTE: Invalid numeric data, '       558,732' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,387,136' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,824,802' , at line 430 column 6.
NOTE: Invalid numeric data, '       212,922' , at line 430 column 6.
Date=19APR2000 CrgoRev1=$3,264,274 CrgoRev2=$558,732 CrgoRev3=$2,387,136
CrgoRev4=$1,824,802 CrgoRev5=$212,922 CrgoRev6=$980,465 comment=Lots of Cargo/Heavy Load
r1=3264274 r2=558732 r3=2387136 r4=1824802 r5=212922 z1=. z2=. z3=. z4=. z5=. i=6
_ERROR_=1 _N_=19
NOTE: Invalid numeric data, '     3,295,010' , at line 430 column 6.
NOTE: Invalid numeric data, '       556,194' , at line 430 column 6.
NOTE: Invalid numeric data, '     2,136,315' , at line 430 column 6.
NOTE: Invalid numeric data, '     1,813,862' , at line 430 column 6.
NOTE: Invalid numeric data, '       223,224' , at line 430 column 6.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be
         printed.
Date=20APR2000 CrgoRev1=$3,295,010 CrgoRev2=$556,194 CrgoRev3=$2,136,315
CrgoRev4=$1,813,862 CrgoRev5=$223,224 CrgoRev6=$972,671 comment=Medium Filled r1=3295010
r2=556194 r3=2136315 r4=1813862 r5=223224 z1=. z2=. z3=. z4=. z5=. i=6 _ERROR_=1 _N_=20
NOTE: There were 50 observations read from the data set SASUSER.QUARTER2.
NOTE: The data set WORK.A has 50 observations and 19 variables.
NOTE: DATA statement used (Total process time):
      real time           0.43 seconds
      cpu time            0.32 seconds


 

PaigeMiller
Diamond | Level 26
NOTE: Invalid numeric data, '    $3,360,224' , at line 411 column 6.

 You don't have a numeric variable, you have a character variable that begins with spaces and a dollar sign and contains two commas.

 

Thus the PUT function does not know how to turn this into a number using the DOLLAR format, because it is not a number.

 

You do not need the PUT function here, the value is already in the proper appearance (which is what I think you are trying to do). If this doesn't work, then explain the output you want to see from this step, in the example where the input is ' $3,360,224', what output do you want from this step?

--
Paige Miller
krishnaarrora
Calcite | Level 5
@PaigeMiller
For example, I have a value like this $3,360,224(numeric type value) and I wanted it as 3,360,224, without the dollar sign. Now When I use an input function to get the desired result( which I get from the input function), but in the logs, it states " Numeric values have been converted to character values" which doesn't make any sense to me because according to the concept input function converts char to num, not the other way around. That what confuses me
Tom
Super User Tom
Super User

@krishnaarrora wrote:
@PaigeMiller
For example, I have a value like this $3,360,224(numeric type value) and I wanted it as 3,360,224, without the dollar sign. Now When I use an input function to get the desired result( which I get from the input function), but in the logs, it states " Numeric values have been converted to character values" which doesn't make any sense to me because according to the concept input function converts char to num, not the other way around. That what confuses me

If you have a NUMERIC variable that is displayed like that then you have attached the DOLLAR format to it. If you want it to display with the commas every three digits but without the dollar sign then switch to using the COMMA format instead.  In either case there is no need to change the actual value that is stored in the variable, just the format that will be used to display it for humans to read.

For example if you dataset is like this:

data have;
   x=3360224;
   format x dollar14.;
run;

If you are making a new dataset just add a FORMAT statement.  If you are using the dataset in a PROC you could just add the FORMAT statement to the PROC step.  If you want to change the format attached without re-writing the dataset use PROC DATASETS.

PaigeMiller
Diamond | Level 26

@krishnaarrora wrote:
@PaigeMiller
For example, I have a value like this $3,360,224(numeric type value) and I wanted it as 3,360,224, without the dollar sign. Now When I use an input function to get the desired result( which I get from the input function), but in the logs, it states " Numeric values have been converted to character values" which doesn't make any sense to me because according to the concept input function converts char to num, not the other way around. That what confuses me

If your input variable is numeric (that's what SAS is telling us), it has a value of 3360224 with no commas and no dollar sign. The fact that you see a dollar sign and commas is because of a format that has been applied to it, but the value itself has no commas and no dollars signs. What do you want as the output? If you want 3,360,224 with commas but no dollar sign, all you have to do is apply the COMMA. format to it. There is no need for PUT or INPUT. The variable remains numeric 3360224, but its appearance changes ( because of the COMMA. format) to 3,360,224.

 

This is an extremely important concept. FORMATs can change the appearance of the value, but the value itself of 3360224 doesn't change. If you want a value to APPEAR differently (no dollar sign), then changing the format — and not creating a character variable — is all you need to do.

 

--
Paige Miller
Tom
Super User Tom
Super User

So the issue has nothing to do with arrays.  You are just using wrong formats and/or informats in your PUT() and/or INPUT() function calls.

The key parts of the log.

...
410  r(i)=input(k(i),comma14.);        /* this is working*/
411  z(i)=put(r(i),dollar14.);             /* this is giving error*/
...
NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      410:12
NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      411:1
NOTE: Invalid numeric data, '    $3,360,224' , at line 411 column 6.

You told the data step the variables K[*] were character, but they were numeric.

You told the data step the variables Z[*] were character, but they were numeric.

 

The reason the first one "worked" is that SAS converted K[i] to a string, using the BEST12 format, and the COMMA informat was able to convert it back to a number.

 

The reason the second one "failed" is that SAS cannot autoconvert a string made using the DOLLAR format into a number.

 

What are you actually trying to do?  Perhaps you just put the wrong variables into the arrays?

 

 

yabwon
Onyx | Level 15
data want;
set have;
array k(5) $ CrgoRev1-CrgoRev5; /* dollar $ was missing */
array r(5) r1-r5;
array z(5) $ 14 z1-z5; /* dollar $ was missing, and the length  */
do i=1 to 5;
  r(i)=input(k(i),comma14.);   
  z(i)=put(r(i), dollar14.);    
end;
run;

and if your "have" data looks like this:

data have;
array x[*] $ 20 CrgoRev1-CrgoRev5
(
"'    $3,360,224'"
"'      $560,116'"
"'    $2,361,846'"
"'    $1,845,832'"
"'      $222,980'"
)
;
run;

you should also use:

r(i)=input(DEQUOTE(k(i)),comma14.); 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



krishnaarrora
Calcite | Level 5
Thanks @yabwon, Understood my mistake I was converting the numeric to the character but not specifying the new variable as char variable. I've used the following code and it worked thank you.
data a;
set sasuser.Quarter2;
array k(5) CrgoRev1-CrgoRev5;
array z(5) $z1-z5;
do i=1 to 5;
z(i)=put(k(i),dollar12.);
end;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 1698 views
  • 2 likes
  • 5 in conversation