BookmarkSubscribeRSS Feed
helannivas88
Obsidian | Level 7

Hi,

 

I'm exporting data from the sas dataset into .txt file with preserving leading spaces. In the sas dataset there are around 50 columns and only one column (REF) has leading spaces.

 

filename XAB "&SOURCE_FILE";

data _null_;
set TEMP_XAB;
file XAB dsd dlm='|';
put (_all_) (+0)  REF $char15.;;
run;

 

But if I have the code as like above, it creates an extra column with leading spaces for REF column in txt. file.

Even I will not able to put all the 50 column names and only for that REF column will have that char format in the put statement.

 

Is there any possible way to have that only column as format char string and the remaining column as it is from the dataset before creating the .txt file.

 

Thanks

 

Thanks 

 

 

1 REPLY 1
ballardw
Super User

Data is critical for such as this.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

Since this is an output related task then likely only need to provide 5 lines of actual data.

 

THEN you need to provide text as you expect that output to appear. Post such text in a code box opened with the </> because the main message windows will remove white space characters like blanks.

 

It is extremely likely that your existing vales do not contain leading spaces.

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
  • 1 reply
  • 517 views
  • 1 like
  • 2 in conversation