Page 1 of 1

Conversion of Binary to Decimal

PostPosted: Mon Dec 21, 2020 12:24 am
by abejacb
I have a file and file declared in SAS as follows.
@01 panelist ib4.
@05 system   ib2.
@07 units    rb4.
@11 dealbits pib1.
@12 footprnt pib2


Now I need to convert all of these into decimal using DFORT. Can you please provide the OUTREC FIELDS.

Re: Conversion of Binary to Decimal

PostPosted: Mon Dec 21, 2020 1:52 am
by sergeyken
What do you mean by “decimal” in this context?

Please, clarify.

Note: it could be
P’1234’=X’01234C’
Z’1234’=X’F1F2F3C4’
C’1234’=X’F1F2F3F4’
... and many others...

Re: Conversion of Binary to Decimal

PostPosted: Mon Dec 21, 2020 2:35 pm
by NicC
Please give sample input/output. Use code tags when posting code and data so that everything aligns and is easier to read.

Re: Conversion of Binary to Decimal

PostPosted: Mon Dec 21, 2020 3:47 pm
by abejacb
Thanks for the quick response.

Example : if the variable is declared as 9(04) comp, I need to get it converted to 9(04) using DFSORT.

Re: Conversion of Binary to Decimal

PostPosted: Mon Dec 21, 2020 6:26 pm
by sergeyken
abejacb wrote:Thanks for the quick response.

Example : if the variable is declared as 9(04) comp, I need to get it converted to 9(04) using DFSORT.


I recommend you to start from reading manuals rather than writing to forums... :(

... BUILD=(...,pos,2,BI,TO=ZD,LENGTH=4,...)

Re: Conversion of Binary to Decimal

PostPosted: Mon Dec 21, 2020 6:29 pm
by NicC
Look in the manual at INREC / Reformatting / Example 4 as a start point

Re: Conversion of Binary to Decimal

PostPosted: Wed Dec 23, 2020 5:25 pm
by abejacb
Thanks NicC and Sergeyken.

Re: Conversion of Binary to Decimal

PostPosted: Wed Dec 23, 2020 6:39 pm
by sergeyken
abejacb wrote:Thanks NicC and Sergeyken.

Anyway, I strictly recommend you to read manuals, carefully. There are hundreds, or thousands other tips and tricks you could learn, besides of those few answers to specific questions you can get at the forum.