2017-03-14 153 views
0

我在報告數據子組的大量值列表。我有我目前想要的形式的數據,只需要進行一些修改即可。我試圖找到一種方法來在每個頁面的第一行上打印子組的值,但對於其餘的值則爲空。Proc Report - 在每頁的第一行打印ID

我試圖做使用的ID選擇這多種方式define,使用compute after塊,compute after _page_,分頁列,並通過使用by聲明,但我不能用這些方法保持我的數據結構。

下面是一些示例數據和基本PROC報告:

/* basic data */ 
data test; 
    input ID $ variable1 $ variable2 $; 
    datalines; 
A Lemon Yellow 
A Orange Red 
A Lemon Blue 
A Apple Green 
A Lemon Yellow 
A Orange Red 
A Lemon Blue 
A Apple Green 
A Lemon Yellow 
A Orange Pink 
A Lemon Blue 
A Apple Red 
B Lemon Yellow 
B Orange Red 
B Lemon Blue 
B Apple Green 
B Lemon Yellow 
B Orange Red 
B Lemon Blue 
B Apple Green 
B Lemon Yellow 
B Orange Pink 
B Lemon Blue 
B Apple Red 
; 
run; 

/* output several times to cover multiple pages */ 
data test2; 
set test; 
if id = "A" then do; 
output; 
output; 
output; 
end; 

output; 
run; 

/* proc report */ 
ods pdf; 
proc report data = test2 nocenter nowd ; 

define ID/order id ; 
define variable1/display; 
define variable2 /display; 

compute after ID; 
    line ''; 
    endcomp; 

run; 
ods pdf close; 

因此,在這個例子中爲A和B的值在多個網頁上。我希望A和B出現在他們的第一個觀察和第一個觀察在一個新的頁面上。

任何幫助一如既往的讚賞。

+0

什麼是您的輸出文件類型PDF,RTF,文本,PowerPoint,Excel? – Reeza

+0

輸出爲PDF格式,如測試過程報告 –

+0

使用BYVAL嘗試帶有標題的BY組。 – Reeza

回答

0

目前尚不清楚你想要什麼,但這裏有幾個選項。其中:compute before _page_。這可以讓你把它放在桌子上作爲第一個單元格,但看起來有點......奇怪。

二:定義一個by組。這在by組的開頭打印出來。

*COMPUTE BEFORE _PAGE_ option; 

ods pdf file="c:\temp\test.pdf"; 
proc report data = test2 nocenter nowd ; 

define ID/order id ; 
define variable1/display; 
define variable2 /display; 

compute after ID; 
    line ''; 
    endcomp; 

compute before _page_; *prints ID here - can add more text if you want; 
    line ID $; 
endcomp; 

run; 
ods pdf close; 


*BY groups; 

ods pdf file="c:\temp\test.pdf" startpage=never; 
proc report data = test2 nocenter nowd ; 
by id;         *adding by group here; 
define ID/order id ; 
define variable1/display; 
define variable2 /display; 

compute after ID; 
    line ''; 
    endcomp; 

run; 
ods pdf close;