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

Hi All,

I am trying to convert a Numeric value to packed decimal value and it is not getting converted. In output fle it is showing as zeros.

Below is my code.

 

 In input file I have a below field defined as Numeric at position 100 and below conversion menthod I used.

 

@100 cnt_Mos_Deln   $03      has value as 006

Cnt_Mos_Ddlpi = INPUT(Cnt_Mos_Deln,??PD3.)

 

in output file, it is defined as,

Cnt_Mos_Ddlpi  PD3.

 

But above code gives zeros(in Hex) in this field.

 

So can I any one please help?

1 ACCEPTED SOLUTION
7 REPLIES 7
SASKiwi
PROC Star

Where are you running this code? If it's not being run on a mainframe you will probably need to use S370PD. 

durgesh101
Calcite | Level 5
Yes, I am executing code on Mainframe.
Kurt_Bremser
Super User

Don't use a pd informat in the input function when you have readable data in the string. Use a simple 3. instead.

 

When something unexpected happens, always look at the log.

durgesh101
Calcite | Level 5

Code:

 

Data Mrtgfinl;
   Infile Mrtgfinl;
   Input @001 nbr_loan_midas $09.
            @273 Cnt_Mos_Deln $03

 

 

 

PUT 'Cnt_Mos_Deln ' Cnt_Mos_Deln= ;
Cnt_mos_ddlpi = INPUT(Cnt_Mos_Deln,??pd3.);
CALL SYMPUT('Cnt_mos_ddlpi ',Cnt_mos_ddlpi);
Put 'Cnt_mos_ddlpi ' Cnt_mos_ddlpi ;

 

 

Output:

Cnt_Mos_Deln Cnt_Mos_Deln=006
Cnt_mos_ddlpi . ,

 

 

 

 

 

Astounding
PROC Star

I'm not sure whether I can trust the program you are showing, since it is missing at last one semicolon.  But this would definitely be wrong:

 

@100 cnt_Mos_Deln   $03 

 

This gets the value from column 3, not from columns 100-102.  You would have to use a dot instead as part of the informat:  $3.

durgesh101
Calcite | Level 5

Below code worked for me

 

Cnt_mos_ddlpi = INPUT(Cnt_Mos_Deln,??3.);

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 7 replies
  • 4047 views
  • 1 like
  • 4 in conversation