There are good replies to this question from @PaigeMiller @Reeza @Kurt_Bremser all worth reading. What I am going to do is explain how to troubleshoot this question, and eventually get to the answer. The first thing to do is simplify the issue, by identifing the where the issue is occurring and focusing on that. The error message gives us the first clue, indicating an issue with the PUT function ERROR: Numeric format F in PUT function requires a numeric argument.
In the code we can see there's just 1 line containing a PUT function, and really one expression:
INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.)
Now we want to create a simple data step program to simulate the variables that this expression uses, and break this expression up into individual function calls:
data _null_ ;
/* INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.) */
/* create the variables used in the expression above */
AccNrSet=1234 ;
acc_no="5678" ;
serial_no="9012" ;
put "Start " AccNrSet= acc_no= serial_no= ; ;
/* Break the expression up into small chuncks */
/* INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.) */
a=PUT(ACC_NO,13.) ;
put "1 " a= ;
/* INPUT(PUT(COMPRESS(INPUT(a,$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.) */
b=INPUT(a,$13.) ;
put "2 " b= ;
/* INPUT(PUT(COMPRESS(b||PUT(SERIAL_NO,Z3.)),$16.),16.) */
c=PUT(SERIAL_NO,Z3.) ;
put "3 " b= ;
/* INPUT(PUT(COMPRESS(b||c),$16.),16.) */
d=COMPRESS(b||c) ;
put "4 " b= ;
/* INPUT(PUT(d,$16.),16.) */
e=PUT(d,$16.) ;
put "5 " b= ;
/* INPUT(e,16.) */
f=INPUT(e,16.) ;
put "6 " b= ;
run ;
I pulled the variable definitions from the other replies in the post, then took the expression and broke it up into individual function calls. I also added comments and put statements so I could see what the values were as the code ran in the log:
47 data _null_ ;
48
49 /* INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.) */
50 /* create the variables used in the expression above */
51 AccNrSet=1234 ;
52 acc_no="5678" ;
53 serial_no="9012" ;
54 put "Start " AccNrSet= acc_no= serial_no= ; ;
55 /* Break the expression up into small chuncks */
56 /* INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.) */
57 a=PUT(ACC_NO,13.) ;
58 put "1 " a= ;
59 /* INPUT(PUT(COMPRESS(INPUT(a,$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.) */
60 b=INPUT(a,$13.) ;
61 put "2 " b= ;
62 /* INPUT(PUT(COMPRESS(b||PUT(SERIAL_NO,Z3.)),$16.),16.) */
63 c=PUT(SERIAL_NO,Z3.) ;
---
48
ERROR 48-59: The format $Z was not found or could not be loaded.
64 put "3 " b= ;
65 /* INPUT(PUT(COMPRESS(b||c),$16.),16.) */
66 d=COMPRESS(b||c) ;
67 put "4 " b= ;
68 /* INPUT(PUT(d,$16.),16.) */
69 e=PUT(d,$16.) ;
70 put "5 " b= ;
71 /* INPUT(e,16.) */
72 f=INPUT(e,16.) ;
73 put "6 " b= ;
74
75 run ;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
As you can see the code failed to compile and reported the following error (granted not identical but similar to the error reported in the post):
63 c=PUT(SERIAL_NO,Z3.) ;
---
48
ERROR 48-59: The format $Z was not found or could not be loaded.
Next let's review the PUT function documentation (I've just copied the important part):
Restriction
The format. must be of the same type as the source, either character or numeric. That is, if the source is character, the format name must begin with a dollar sign, but if the source is numeric, the format name must not begin with a dollar sign.
After reviewing the documentation and the error, we can see the variable serial_no is a character variable, so as per the documentation, the format name MUST begin with a dollar sign. The format is Z3. which doesn't start with a dollar sign ($) and hence we get an error.
... View more