keep leading blanks

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

keep leading blanks

Hello,

I have a data the charactor variable with leading blanks.  I would like to keep the leading blanks when it is printed out.  Could you please share your ideas how to do it?  Thank you!

data test;

  length v $5.;

  v = '    v';

run;

proc print data=test; run;



Accepted Solutions
Solution
‎04-22-2015 08:46 AM
Super User
Posts: 10,018

Re: keep leading blanks

Ha. What kind of ODS destination are you using ?

data test;

  length v $20.;

  v = '~_~_~_~_~_~_~_~_v';

run;

ods escapechar='~';

ods html file='x.html' style=sasweb;

proc print data=test; run;

ods html close;

View solution in original post


All Replies
Super User
Posts: 3,250

Re: keep leading blanks

I suspect you want right justification when printing V rather than keeping leading blanks. How you do this depends on what type of output you are using with PROC PRINT.

Are you using ODS HTML which is the default output for recent SAS releases or someting else?

Contributor
Posts: 31

Re: keep leading blanks

Thank you, SASKiwi!

I actually want the values to have indentation instead of

right justification.  I use ODS HTML.  If PROC REPORT works or not?

Super User
Posts: 3,250

Re: keep leading blanks

Super User
Super User
Posts: 7,942

Re: keep leading blanks

To note, the key part of the code is the asis=on.  This tells the report to preserve blanks:

proc report...

     define xyz / style(column)=[asis=on];

...

Super User
Posts: 10,018

Re: keep leading blanks

You really should post it at ODS and REPORT forum , since it is about proc report . and Cynthia@sas will give you answer.

You are indeed doing a Table/Listing about SDTM . If I was right, Next time , you will ask how to keep trailing blanks .

data test;

  length v $5.;

  v = '~_~_v';

run;

ods escapechar='~';

proc print data=test; run;

Super Contributor
Posts: 435

Re: keep leading blanks

When I ran your code in SAS EG 7.1, proc print output displays only 'v' without any leading blanks.

Solution
‎04-22-2015 08:46 AM
Super User
Posts: 10,018

Re: keep leading blanks

Ha. What kind of ODS destination are you using ?

data test;

  length v $20.;

  v = '~_~_~_~_~_~_~_~_v';

run;

ods escapechar='~';

ods html file='x.html' style=sasweb;

proc print data=test; run;

ods html close;

Contributor
Posts: 31

Re: keep leading blanks

Thank you for your input!!

I didn't notice the question was not in a right forum but I am realy thankful your help.  I know there are many ways (proc report, ods escapechar) to get the job done, but with ods escapechar, I can also bold/color the text and with less program modification.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 1280 views
  • 6 likes
  • 5 in conversation