- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi
My code is
PROC SQL;
CREATE TABLE TEST AS
SELECT NEW_ACC,ACC_NO
FROM WRK.BRACC_SYST_04 A
INNER JOIN WORK.CARD99_PARSED B
ON A.AccNrSer = INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.)
;QUIT;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your PUT function requires a numeric variable, you are trying to use it on a character variable.
For everyone's benefit, from now on do not separate the errors in the log from the code in the log. Show us the ENTIRE log so we can see the code as it appears in the log, plus the ERRORs, WARNINGs and NOTEs.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
below is the log
1 The SAS System 16:51 Tuesday, January 11, 2022
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program (2)';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HtmlBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24
25 GOPTIONS ACCESSIBLE;
26 PROC SQL;
27 CREATE TABLE TEST AS
28 SELECT NEW_ACC,ACC_NO
29 FROM WRK.BRACC_SYST_04 A
30 INNER JOIN WORK.CARD99_PARSED B
31
32 /*ON A.AccNrSer = INPUT(COMPRESS((PUT(B.ACC_NO,Z13.))||PUT(B.SERIAL_NO,Z3.)),16.)*/
33 ON A.AccNrSer = INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.)
34 /*ON A.NEW_ACC = INPUT(B.ACC_NO,11.)*/
35
36 ;
ERROR: Numeric format F in PUT function requires a numeric argument.
ERROR: Numeric format Z in PUT function requires a numeric argument.
ERROR: Numeric format F in PUT function requires a numeric argument.
ERROR: Numeric format Z in PUT function requires a numeric argument.
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM| STOP| _DISARM| 2022-01-11T17:42:00,469+02:00| _DISARM| WorkspaceServer| _DISARM| SAS|
_DISARM| | _DISARM| 1625220| _DISARM| 31887360| _DISARM| 13| _DISARM| 36| _DISARM| 0| _DISARM| 40| _DISARM| 0.000000|
_DISARM| 0.001953| _DISARM| 1957534920.468052| _DISARM| 1957534920.470005| _DISARM| 0.000000| _DISARM| | _ENDDISARM
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM| STOP| _DISARM| 2022-01-11T17:42:00,470+02:00| _DISARM| WorkspaceServer| _DISARM| SAS|
_DISARM| | _DISARM| 115344| _DISARM| 31887360| _DISARM| 13| _DISARM| 36| _DISARM| 0| _DISARM| 40| _DISARM| 0.000000| _DISARM|
0.000901| _DISARM| 1957534920.469315| _DISARM| 1957534920.470216| _DISARM| 0.000000| _DISARM| | _ENDDISARM
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
36 ! QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2022-01-11T17:42:00,479+02:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| |
_DISARM| 1111285760| _DISARM| 31887360| _DISARM| 13| _DISARM| 36| _DISARM| 0| _DISARM| 40| _DISARM| 0.010000| _DISARM|
0.015457| _DISARM| 1957534920.463991| _DISARM| 1957534920.479448| _DISARM| 0.010000| _DISARM| | _ENDDISARM
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
2 The SAS System 16:51 Tuesday, January 11, 2022
system cpu time 0.00 seconds
memory 5900.50k
OS Memory 36264.00k
Timestamp 2022/01/11 05:42:00 PM
Step Count 47 Switch Count 0
Page Faults 0
Page Reclaims 21
Page Swaps 0
Voluntary Context Switches 5
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 0
37
38 GOPTIONS NOACCESSIBLE;
39 %LET _CLIENTTASKLABEL=;
40 %LET _CLIENTPROCESSFLOWNAME=;
41 %LET _CLIENTPROJECTPATH=;
42 %LET _CLIENTPROJECTPATHHOST=;
43 %LET _CLIENTPROJECTNAME=;
44 %LET _SASPROGRAMFILE=;
45 %LET _SASPROGRAMFILEHOST=;
46
47 ;*';*";*/;quit;run;
48 ODS _ALL_ CLOSE;
49
50
51 QUIT; RUN;
52
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When you're building a nested function like that, I recommend testing each portion and then adding it together slowly.
For example this: INPUT(PUT(B.ACC_NO,13.),$13.) doesn't seem super useful.
data check;
set card99_parsed (obs=100);
accrNrSer = INPUT(PUT(COMPRESS(INPUT(PUT(B.ACC_NO,13.),$13.)||PUT(SERIAL_NO,Z3.)),$16.),16.);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Good point @Reeza , none of this seems useful or necessary to concatenate two ID variables.
How about this:
ON A.AccNrSer = cat(B.ACC_NO,PUT(SERIAL_NO,Z3.))
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have apply the the below , however am still getting the same error message
PROC SQL;
CREATE TABLE TEST AS
SELECT NEW_ACC,ACC_NO
FROM WRK.BRACC_SYST_06 A
INNER JOIN WORK.CARD99_PARSED B
ON A.AccNrSer = cat(B.ACC_NO,PUT(B.SERIAL_NO,Z3.))
;QUIT;
log
1 The SAS System 09:01 Wednesday, January 12, 2022
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program (2)';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HtmlBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24
25 GOPTIONS ACCESSIBLE;
26 PROC SQL;
27 CREATE TABLE TEST AS
28 SELECT NEW_ACC,ACC_NO
29 FROM WRK.BRACC_SYST_06 A
30 INNER JOIN WORK.CARD99_PARSED B
31
32 ON A.AccNrSer = cat(B.ACC_NO,PUT(B.SERIAL_NO,Z3.))
33
34 ;
ERROR: Numeric format Z in PUT function requires a numeric argument.
ERROR: Expression using equals (=) has components that are of different data types.
ERROR: Numeric format Z in PUT function requires a numeric argument.
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM| STOP| _DISARM| 2022-01-12T09:18:00,485+02:00| _DISARM| WorkspaceServer| _DISARM| SAS|
_DISARM| | _DISARM| 1625279| _DISARM| 29790208| _DISARM| 13| _DISARM| 36| _DISARM| 0| _DISARM| 8772712| _DISARM| 0.000000|
_DISARM| 0.002279| _DISARM| 1957591080.483530| _DISARM| 1957591080.485809| _DISARM| 0.000000| _DISARM| | _ENDDISARM
NOTE: MVA_DSIO.OPEN_CLOSE| _DISARM| STOP| _DISARM| 2022-01-12T09:18:00,486+02:00| _DISARM| WorkspaceServer| _DISARM| SAS|
_DISARM| | _DISARM| 115344| _DISARM| 29790208| _DISARM| 13| _DISARM| 36| _DISARM| 0| _DISARM| 8772712| _DISARM| 0.000000|
_DISARM| 0.001916| _DISARM| 1957591080.484163| _DISARM| 1957591080.486079| _DISARM| 0.000000| _DISARM| | _ENDDISARM
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
34 ! QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2022-01-12T09:18:00,486+02:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| |
_DISARM| 1109712896| _DISARM| 29790208| _DISARM| 13| _DISARM| 36| _DISARM| 0| _DISARM| 8772712| _DISARM| 0.000000| _DISARM|
0.014387| _DISARM| 1957591080.472146| _DISARM| 1957591080.486533| _DISARM| 0.000000| _DISARM| | _ENDDISARM
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 5897.15k
OS Memory 34216.00k
Timestamp 2022/01/12 09:18:00 AM
Step Count 32 Switch Count 0
2 The SAS System 09:01 Wednesday, January 12, 2022
Page Faults 0
Page Reclaims 56
Page Swaps 0
Voluntary Context Switches 5
Involuntary Context Switches 5
Block Input Operations 0
Block Output Operations 0
35
36 GOPTIONS NOACCESSIBLE;
37 %LET _CLIENTTASKLABEL=;
38 %LET _CLIENTPROCESSFLOWNAME=;
39 %LET _CLIENTPROJECTPATH=;
40 %LET _CLIENTPROJECTPATHHOST=;
41 %LET _CLIENTPROJECTNAME=;
42 %LET _SASPROGRAMFILE=;
43 %LET _SASPROGRAMFILEHOST=;
44
45 ;*';*";*/;quit;run;
46 ODS _ALL_ CLOSE;
47
48
49 QUIT; RUN;
50
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
COMPRESS is a character function, so you can't use PUT with a numeric format for it.
And SERIAL_NO is obviously a character variable, so again you cannot use a numeric format for it.
Maxim 3: Know Your Data.
Inspect the dataset(s) for variable types.
Next get a good picture of the real contents, so you can decide how you must concatenate them.
Show us the data types of the three variable used in the ON clause, ideally by copy/pasting the relevant lines from a PROC CONTENTS output.
Next show typical content of these variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Kurt_Bremser as per you request see below
PROC CONTENTS DATA=WRK.BRACC_SYST_06;
PROC CONTENTS DATA=CARD99_PARSED;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So, AccNrSer is numeric, which you cannot compare to the result of a CAT function, which is character.
The two character variables are both 32 characters long, and since CAT does not remove trailing blanks, the result will be 64(!) characters long, which does not make sense in any way as a number (SAS can't handle more than 15 decimal digits reliably).
From what I see, you first have a problem by storing an account number as a number. You never do calculations with account "numbers", which are rather codes. So you should create this variable as character in the first place when you import your data into SAS.
Next, you need to take care to create the same structure you have in AccNrSer when you concatenate the other two variables; to get this right, we need to know the contents of these, and the contents of a correctly (character!) imported AccNrSer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.