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.);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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