08-08-2014 07:43 AM
Assume, I have a macro, where we have only one argument text= .Let's call that macro test.
This macro should put entered text into .txt.
The question is, Is it possible to put entered text into few lines, just like you would enter into SAS editor.
%test(text=This is just a test. [Pressed ENTER]
This is a new line. [Pressed ENTER]
And I would like to see this text with same structure in .txt as:
This is just a test.
This is a new line.
There is a macro in proceedings, but it uses a special symbol for ENTER (like comma or |).
What I need is pure text with no addings.
08-08-2014 08:21 AM
No, as per the proceedings, a carriage return is a non visable special character. This is the only way to get returns in text. If you can only use pure text, i.e. number/chars then it will all be one line of text.
As for getting this out to a file then:
filename textfile "c:\test.txt";
put "Hello World";
put "Goodbye World";
Will have in the text file the two strings on separate lines - they still have the carriage return!
08-08-2014 08:45 AM
The macro call that you posted would be consider part of the program stream to SAS. This will be parsed just like any other code. SAS does not consider the end of line as different than any other white space when parsing a program.
08-08-2014 09:41 AM
This is the first question I see somebody is wanting to put a newline character into a string. the byte code is: '0a'x
this will cause a lot of issues as you wanted to do something with it we do not understand. The macro-quoting is field full of mines.
Just wanting a nice lay-out than go for ODS.
08-08-2014 11:08 AM
Are you attempting to do something with multiple undefined lines or will it always be a fixed number of lines? If the later, there MAY be a solution if you describe how you intend to use the macro. Otherwise we're flying kind of blind.
08-11-2014 02:40 AM
since it will processed (for output) in later stages, I would suggest you insert the handling instructions appropriate to that stage. Since the stage looks like PUT statement to text, your macro value could look like
'Text1' '0a'x 'Text2' '0a'x 'Text3'
When Text1-3 are in variables named txt1-3, a suitable way of storing the 'target' value in a macro variable could be
CALL SYMPUTX( 'mVar', catx( " '0a'x ", txt1, txt2, txt3 ) ) ;
hope this works for you
08-08-2014 11:27 AM
Maybe this would be adequate.