BookmarkSubscribeRSS Feed
Siddhartha
Calcite | Level 5

Hi,

I was using a text file from mainframe in one of the program, there are some comp-3 fields. While using this fields with the format starting with PDw.d formats.

I am getting the control characters in the output. I am not able to read the format with these characters.

Can any one suggest how to read control character in the output. Below is the screnshot.

Control characters scrnshot.PNG

Thanks & Regards,

Sid

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Can you not do:

data want;

     set have;

     my_new_var=input(substr(var,1,index(var," ")),pdX.Y.);

run;

Siddhartha
Calcite | Level 5

There are almost around 20 fields with the PDw.d format defined in the program.

Below is the format we are using in the PUT statement:

       @127   SUB_TOTAL_AMT               PD5.2                                 

       @132   TAX_AMT                     PD5.2                                

       @137   TOT_INVOICE_AMT             PD5.2  

       @244   CASH_SALE_AMT_P             PD4.2

       @293   STBASE                      PD5.2                                

       @298   STTAX                       PD5.2

Thanks & Regards,

Siddhartha

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, you wouldn't read the control chars in in that type of import.  I would suggest you need to clean the datafile first:

data _null_;

     infile "your_original_file.txt" recfm=n;

     file "cleaned_file.txt" recfm=n;

     input a $char1.;

     if lengthn(compress(upcase(a),"A","n"))=0 then put a;  /* I.e. if character is alphanumeric then output */

run;

Then read that new file in.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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