BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
danacosman
Calcite | Level 5

Hi,

 

My output data (.DAT) is tab-delimited (used proc export) but because some observations have different lengths columns are not properly align. Every variable/column has same length $30. 

 

Example of my output:

 

Capture.JPG

 

 

 

 

 

How I need them to be:
Capture2.JPG

 

 

 

 

 

 

 

 

I tried to use PUT statement but the output didn't change.

 

put  second_column @20 number_column @40;

 

-> this means that sas will start writing second_column starting with 20th character in the line and number_column will always start at 40th character. Did I get it wrong?

 

I'm new to sas and I try to understand it's ways. Any tip would help, thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You need to decide what you actually want.  If you want all the columns to lign up then you want fixed width file format, for example:
https://communities.sas.com/t5/Base-SAS-Programming/exporting-3-datasets-into-one-fixed-width-text-f...

 

If you want to have tab delimited, then that will show the tab in the reader you open it with (each reader is different, for instance if you use notepad to open the file the tab might be 3 characters, open in ord it might tab differently).  This is why I avoid using tab in anything - including in SAS code, as tabs render differently on different systems/applications.  The underlying character is the same, but as that is a special character (like line feed and page break) it is down to the reader to render it.  

View solution in original post

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

You need to decide what you actually want.  If you want all the columns to lign up then you want fixed width file format, for example:
https://communities.sas.com/t5/Base-SAS-Programming/exporting-3-datasets-into-one-fixed-width-text-f...

 

If you want to have tab delimited, then that will show the tab in the reader you open it with (each reader is different, for instance if you use notepad to open the file the tab might be 3 characters, open in ord it might tab differently).  This is why I avoid using tab in anything - including in SAS code, as tabs render differently on different systems/applications.  The underlying character is the same, but as that is a special character (like line feed and page break) it is down to the reader to render it.  

danacosman
Calcite | Level 5

Yes, I wanted fixed width file format.

The linked helped and the solution for me is to use put statement.

Thanks!

Kurt_Bremser
Super User

By definition, a delimited file cannot be aligned. You either have fixed or variable widths, and one uses delimiters to avoid fixed spacings (because of the wasted space in the file, caused by the blanks used for padding).

In a tab-delimited file, the tabs are not there to align, only to separate. What you see is not the real structure of the file, only the way the file is displayed in your current viewer. Other viewers will give you another look. So don't be worried, it's all okay.

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
  • 3 replies
  • 1604 views
  • 1 like
  • 3 in conversation