Changing PUT statement default strip behaviour

Accepted Solution Solved
Reply
Contributor
Posts: 62
Accepted Solution

Changing PUT statement default strip behaviour

Hi Good Evening,

I have a sas program which is reading another sas program and placing in different os.

Q)  Want to read file and print with same indent.

ex:  Data x;

         infile "xyz.txt" truncover;

         input abc $char500.;

       run;

     process few more things on the program......

     Data _null_;

      file "zyx.txt" notitles;

      put x;

     run;

Then problem here is if the x variable has spaces at the begining then it is stripping which I don't want.

ex:   x=             hello

prints x=hello

Please help in this regard.

Thanks .



Accepted Solutions
Solution
‎02-19-2014 07:42 AM
Respected Advisor
Posts: 3,799

Re: Changing PUT statement default strip behaviour

In this case I would use $VARYING format in the put statement.  You will need to find the length of each X before the PUT.

View solution in original post


All Replies
Solution
‎02-19-2014 07:42 AM
Respected Advisor
Posts: 3,799

Re: Changing PUT statement default strip behaviour

In this case I would use $VARYING format in the put statement.  You will need to find the length of each X before the PUT.

Contributor
Posts: 62

Re: Changing PUT statement default strip behaviour

Posted in reply to data_null__

hi mate,

Thanks for the reply.

Could you please give me an example.

data _null_;

  set program;

    lth=length(x);

form=cats('$varying',lth,'.');

    file "text.txt";

    put x form;

run;

but it did not work..

Thank You

Super User
Super User
Posts: 7,050

Re: Changing PUT statement default strip behaviour

put x $varying500. lth ;

Contributor
Posts: 62

Re: Changing PUT statement default strip behaviour

Thanks a lot guys.  It really solved my job.

Thanks again.

Respected Advisor
Posts: 3,799

Re: Changing PUT statement default strip behaviour

I guess you didn't bother to look a the online documentation for $VARYING  :smileyconfused:

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 229 views
  • 4 likes
  • 3 in conversation