BookmarkSubscribeRSS Feed
Mariaho
Calcite | Level 5

Hi,

I'm using the following to create a text delimited file. However for the fields that have null value, the output text file is generating a space between the delimiters. Is there any way to get rid of the blanks ?

I cannot use proc export as I cannot customise the header and trailer (or is it possible to customise headers/trailers in proc export ?)

Thanks  !

data _null_;

  dt= datetime();

  format dt YMDHMS.;

  format Business_Date b8601da.;

  format OBS Z8.;

  format amount_SUM Z20.;

  retain amount_SUM;

  set sas_extract_formatted end=EFIEOD NOBS=OBS;

  FILE  'C:\Users\f051615\rawfile.txt' DLM='~' LINESIZE=1000;    /* Output Text File */

  if _n_ = 1 then do;

  PUT "H~SASX~" Business_Date dt;

  end;

  do;

  amount_SUM=sum(amount_SUM,amount_Final);

  /*put (_all_)(+0);*/

  PUT 'D~'

  Business_Date

  Month_Key

  Period_Id

  Customer_Id

end;

if EFIEOD then do;
   PUT "T~" OBS CEA_SUM;
end;

run ;

3 REPLIES 3
Kurt_Bremser
Super User

Your code was either not correctly pasted or contains errors. The second PUT lacks a semicolon before the end;

I also think that you wanted to output amount_SUM instead of CEA_SUM in the final PUT

To suppress the blanks for empty strings, use the DSD option in the FILE statement.

Mariaho
Calcite | Level 5

thank you !

Sorry I must have copied and pasted incorrectly.

the DSD option worked.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 895 views
  • 0 likes
  • 2 in conversation