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

Hi Dears,

im getting below error in SAS DI, please can you help to resolve this issue.

 

case

when INPUT(SUBSTR(PUT(DBLNSIA ,Z6.),3,4) || SUBSTR(PUT(DBLNSIA ,Z6.),1,2) || '01',11.) = 0 then -1

else INPUT(SUBSTR(PUT(DBLNSIA ,Z6.),3,4) || SUBSTR(PUT(DBLNSIA ,Z6.),1,2) || '01',11.)

end

 

Line 593: ERROR: Numeric format Z in PUT function requires a numeric argument.

 

ERROR: Numeric format Z in PUT function requires a numeric argument.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@dhruvakumar 

You may be having a difficulty understanding what a variable type is. SAS supports two basic types of variables, numeric, that hold values used for arithmetic, and character, that hold text.

 

Sometimes character values look like numbers. These cannot use a numeric type of format.

 

The error message says that is what you have attempted to do.

Two examples of using the Z format. One correct:

data example1;
  /* this a numeric value*/
   x= 3;
   y=put(x,z4.);
run;

one incorrect:

data example2;
  /* this a character value*/
   x= "3";
   y=put(x,z4.);
run;

Running the Example2 code will have a log like:

69   data example2;
70     /* this a character value*/
71      x= "3";
72      y=put(x,z4.);
                ---
                484
NOTE 484-185: Format $Z was not found or could not be loaded.

73   run;

The note about format $Z is because only character formats, whose names will start with $, are allowed with character variables.

In other places, like your case statement that may become an error because of different syntax rules.

 

There may well be a way to make things work as you need but you have not provided 1) any actual examples of the values of your variable or 2) what the expected output for those given values would be.

 

 

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

Variable DBLNSIA is not numeric, so you can't convert it to character using the PUT statement with the Z6. format. Z6. can only work on numeric variables.

--
Paige Miller
dhruvakumar
Obsidian | Level 7

HI Thanks for reply. May I know what can I use there please 

ballardw
Super User

@dhruvakumar wrote:

HI Thanks for reply. May I know what can I use there please 


Kind of need to know what the values of DBLNSIA look like and what you expect for a result.

PaigeMiller
Diamond | Level 26

@dhruvakumar wrote:

HI Thanks for reply. May I know what can I use there please 


Important debugging tool ... look at variable DBLNSIA and see if it is numeric or character, and look at the values of DBLNSIA. Do they look like numbers, or do some of them have non-numeric characters? What do you see?

--
Paige Miller
dhruvakumar
Obsidian | Level 7
##- Please type your reply above this line. No attachments.
character
ballardw
Super User

@dhruvakumar wrote:
##- Please type your reply above this line. No attachments.
character

42 ?!?

PaigeMiller
Diamond | Level 26

@dhruvakumar wrote:
##- Please type your reply above this line. No attachments.
character

So you are trying to use the Z. format on a character variable. This cannot be done. You cannot convert a character variable using the Z. format. 

 

So please explain in words (not SAS code), and give an example or two or three, of what these character variables look like and what you want to convert them into.

--
Paige Miller
Kurt_Bremser
Super User
when INPUT(
  SUBSTR(PUT(DBLNSIA ,Z6.),3,4) ||
  SUBSTR(PUT(DBLNSIA ,Z6.),1,2) ||
  '01',
11.) = 0 then -1

No matter what, you build a string that ends in a 1, and input that; this number can never be zero, so this part of the code makes absolutely no sense.

ballardw
Super User

@dhruvakumar 

You may be having a difficulty understanding what a variable type is. SAS supports two basic types of variables, numeric, that hold values used for arithmetic, and character, that hold text.

 

Sometimes character values look like numbers. These cannot use a numeric type of format.

 

The error message says that is what you have attempted to do.

Two examples of using the Z format. One correct:

data example1;
  /* this a numeric value*/
   x= 3;
   y=put(x,z4.);
run;

one incorrect:

data example2;
  /* this a character value*/
   x= "3";
   y=put(x,z4.);
run;

Running the Example2 code will have a log like:

69   data example2;
70     /* this a character value*/
71      x= "3";
72      y=put(x,z4.);
                ---
                484
NOTE 484-185: Format $Z was not found or could not be loaded.

73   run;

The note about format $Z is because only character formats, whose names will start with $, are allowed with character variables.

In other places, like your case statement that may become an error because of different syntax rules.

 

There may well be a way to make things work as you need but you have not provided 1) any actual examples of the values of your variable or 2) what the expected output for those given values would be.

 

 

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
  • 9 replies
  • 4862 views
  • 2 likes
  • 4 in conversation