| options nocenter;
proc sort data=sashelp.class out=class;
proc report data=class nowd;
|
| Sex Name
Age
F Alice 13 Barbara 13 Carol 14 Jane 12 Janet 15 Joyce 11 Judy 14 Louise 12 Mary 15 ------------------------ M Alfred 14 Henry 14 James 12 Jeffrey 13 John 12 Philip 16 Robert 12 Ronald 15 Thomas 11 William 15 ------------------------ |
Now we try to make it conditional so we get no line after the "F" sex.
| proc report data=class nowd;
columns sex name age; define sex / order width=3 spacing=0; define name / display; define age / display; compute after sex; if sex="M" then do; line @1 "------------------------"; end; endcomp; run; |
The output is exactly the same. We have a dashed line under both sexes.
| Sex Name
Age
F Alice 13 Barbara 13 Carol 14 Jane 12 Janet 15 Joyce 11 Judy 14 Louise 12 Mary 15 ------------------------ M Alfred 14 Henry 14 James 12 Jeffrey 13 John 12 Philip 16 Robert 12 Ronald 15 Thomas 11 William 15 ------------------------ |
And what does it say in the log to tell us we can not do this? I'll
show you.
| 276 proc report data=class nowd;
277 columns sex name age; 278 define sex / order width=3 spacing=0; 279 define name / display; 280 define age / display; 281 compute after sex; 282 if sex="M" then do; 283 line @1 "------------------------"; 284 end; 285 endcomp; 286 run; NOTE: There were 19 observations read from the data set WORK.CLASS.
|
There is nothing in the log to tell us something is wrong, even though it has not worked in the way we expected.
We can change what gets displayed by the line statement and show nothing
for sex="F" but we can't get rid of the line using this method.
| proc report data=class nowd;
columns sex name age; define sex / order width=3 spacing=0; define name / display; define age / display; compute after sex; msg="------------------------"; if sex="F" then msg=""; line @1 msg $24.; endcomp; run; |
| Sex Name
Age
F Alice 13 Barbara 13 Carol 14 Jane 12 Janet 15 Joyce 11 Judy 14 Louise 12 Mary 15 M Alfred
14
|
| proc report data=class nowd;
columns sex name age; define sex / order width=3 spacing=0; define name / display; define age / display; compute after sex; msg="------------------------"; if sex="F" then len=0; else len=24; line @1 msg $varying24. len; endcomp; run; |
Now we get what we want.
| Sex Name
Age
F Alice 13 Barbara 13 Carol 14 Jane 12 Janet 15 Joyce 11 Judy 14 Louise 12 Mary 15 M Alfred 14 Henry 14 James 12 Jeffrey 13 John 12 Philip 16 Robert 12 Ronald 15 Thomas 11 William 15 ------------------------ |
| options nocenter ps=40 ;
proc report data=sasuser.adv headline headskip nowd; columns patno amsoc; define patno / display; define amsoc / display; compute before; len=71; len2=len; text=repeat("_",135); endcomp; compute after _page_; line @3 text $varying. len; endcomp; compute after; len=0; line @3 text $varying. len2; endcomp; run; |
Go back to the home page.
E-mail the macro and web site author.