BookmarkSubscribeRSS Feed
rohitkrishna
Calcite | Level 5

Hi All

I have an issue while converting log master to CSV format I am facing a license length issue first, I have given license format PD5. it contains 10 positions 

I mean 10 digits while righting to o/p file I have given license z10.

but in the o/p file, it showing 0 instead of 1 so the value of license not picking correct record  

so kindly plz provide the solution of the problem 

 

Thanks & Regards 

Rohit 

 

5 REPLIES 5
rohitkrishna
Calcite | Level 5
INFILE LSFIV**0 TRUNCOVER;                      
INPUT   TEXT                           $CHAR26. 
        CRTD_TS                        $CHAR26. 
        TEXT                           $CHAR13. 
        LICENCE_NO                     PD5.     

Format O/P file 
                                                  
 File LSFI2**1;  /* Output version of LSFI*** */ 
 PUT @1 LICENCE_NO                     Z10.       

+++++++++++++++++
 licencec = PUT(licence_no,Z10.);  
with Delimiter
                                             
Recout = 'D' || delimtr ||                   
     trim (Left(licencec     )) || Delimtr;

===============================================
Actual i/p file in log master format
CLST0*0 TLS27**_PAY**_CN**2020-06-08-08.32.18.129184     ü3* tM  

======================================================
The o/p 
D|0000044479|"PY*_IN*_00#$$$1309.DAT"|20200717|"ACC"|
+++++++++++++++++++++++++++++++++++++++++++++++++++
The Expected o/p 
D|1000044479|"PY*_IN*_00#$$1309.DAT"|20200717|"ACC"|

the Actual o/p as per the above one getting missing the one value it reading only 9 positions only that the region the first position of the license it seems 0 instead of 1 so kindly plz provide the solution the above problem 

Thanks & Regards 
Rohit



Kurt_Bremser
Super User

The PD format uses the last nibble (half-byte) to store the sign. This means that for every given number of bytes, you will always have an odd number of decimal digits stored. To store 10 digits, you need 6 bytes, which means that you actually have space for 11 digits and the sign.

I suggest you restructure your INPUT statement like this:

input
  TEXT          $CHAR26. 
  CRTD_TS       $CHAR26. 
  TEXT          $CHAR12. 
  LICENCE_NO    PD6.
;
ballardw
Super User

Where do you think that you are adding a 1 to first position of the value.

 licencec = PUT(licence_no,Z10.);  

Creates a 10 character output that will start with a 0 if the Licence_no does not have 10 signficant digits.

The next code that you show:

                                             
Recout = 'D' || delimtr ||                   
     trim (Left(licencec     )) || Delimtr;

Does not do anything to insert a 1 in the first position. The only thing done to Licencec would be to remove leading spaces with Left, which it wont' have, and trim any trailing spaces, which it is very likely not to have.

 

That is why I ask where you think you inserted a 1 into the first position?

 

I will also say the showing:

Actual i/p file in log master format
CLST0*0 TLS27**_PAY**_CN**2020-06-08-08.32.18.129184     ü3* tM  

without indicating the exact positions that might contain the license number is not helpful at all and even with that we would need the definition of your PD5 informat to make any sense of that.

If you are expecting the PD5 informat to have the leading 1 then you don't want to use Z10 to create a text value but a corresponding custom format. Or other manipulation.

ballardw
Super User

Are you opening the CSV with spreadsheet software? Depending on actual values in a CSV file some spreadsheet software will "decide" on characteristics and possibly change values.

I suggest opening the CSV with a text viewer to see if the values were written as intended. Be aware that if you opened the file in spreadsheet software and then saved the values may have been permanently altered and you should recreate the CSV file before checking.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 705 views
  • 0 likes
  • 3 in conversation