05-22-2014 07:02 AM
Does anzone help me out how to change the title stement in the output window based on condition
ex:%global x d;
input var1 date;
Here i need if x=var1 and d=date then title="CCCCCCCCCCCCCCCCCCCCCC"
if x ne var1 and d=date then title="BBBBBBBBBBBBBBBBBBBBB"
if x ne var1 and d ne date then title="VVVVVVVVVVVVVVVVV";
Thanks in advance....
05-22-2014 07:06 AM
Use call execute in your datastep.
call execute('title "'||strip(your title)||'";');
call execute('proc print...');
05-22-2014 07:21 AM
Since you cannot change the title while proc print is running, and you placed the condition on values of the dataset to be printed, your problem is unsolvable.
05-22-2014 08:01 AM
Make a macro :
%global x d; %let x=ccc; %let date=23may2014; %let flag=N; data test; input var1 $ date :$20.; if var1="&x" then call symputx('flag','Y'); datalines; aaa 21may2014 bbb 22may2014 ccc 23may2014 run; %macro m; %if &flag eq Y %then %do; Title "YES.............."; %end; %else %do;title "NO...."; %end; proc print; run; %mend m; %m
05-22-2014 11:13 AM
Well, you do have to understand that you have three observations, but there can only be one title. Assuming you work out which of the three observations determines the title ...
You can create a macro variable holding the title's text, instead of writing a macro. Right before the DATALINES statement, add along these lines:
if var1="&x" and d="&date" then call symput('text', 'CCCCCCCCCCCCCCCCCCCCCCC');
else if var1 ne "&x" and d="&date" then call symput('text', 'BBBBBBBBBBBBBBBBBBBBBBB');
else call symput('text', 'VVVVVVVVVVVVVVVVVVVVVVVVV');
Then below, your TITLE statement simply becomes:
05-22-2014 12:04 PM
The closest you might get is to create your "title" variable and then
Depending on the version of SAS you are using there are options to modify the appearance of the By line that will appear before the printed data.
05-26-2014 01:33 AM
Thank you so much for your response.I tried all above,espesially programs by Ksharp and Astounding It was executed successfullz without anz errors,But it did not give the expected resulz.Itäs not able to change the title statement.Could zou guide me more please.
05-26-2014 01:59 AM
As was already stated, you CANNOT change the title during execution of a proc or data step. You can just try to simulate it.
One way to achieve the desired result is to generate the whole output manually with a data _null_ step. But this means you have to write the whole report syntax in eg html. Which takes knowledge in css, html and the intricacies of the put statement.
05-26-2014 01:36 PM
Post an example of what your data looks like and EXACTLY what you expect to see as the output and we can help you get there. The way your question is currently phrased it won't work, however there may be other solutions, some easier than others to get what you want.