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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2549 views
  • 1 like
  • 3 in conversation