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?
You're still using the wrong informat in the input() function.
Where are you running this code? If it's not being run on a mainframe you will probably need to use S370PD.
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.
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 . ,
You're still using the wrong informat in the input() function.
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.
Below code worked for me
Cnt_mos_ddlpi = INPUT(Cnt_Mos_Deln,??3.);
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.