DATA Step, Macro, Functions and more

Proc Report - add headline with values of order variable

Reply
New Contributor
Posts: 2

Proc Report - add headline with values of order variable

Hi there,

I have a variable "studytype" and further variables var1, var2, var3. Now I want to create an Excel file, that lists all data with var1-var3, grouped by studytype. 

Before a new studytype starts, I want to add a Headline mentioning the studytype.

 

For example:

studytype var1 var2 var3

A  1 abcd 1111

A  1 werewre 234234

B  1 jwlkerjwerkl 3423432

 

Should appear like:

A

1 abcd 111

1 werewere 234324

 

B

1 jwlkerjwerkl 3423432

 

My code:

Ods  tagsets.ExcelXP path=&path. file='out.xml' style=seaside;

proc report data=mydata nowd;
column studytype var1 var2 var3;
define studytype/ order noprint;
break before studytype / skip;
compute before studytype;
line'';
endcomp;
run;

ods tagsets.ExcelXP close;

It´s quite close to what I need, but how can I get the studytype (current value of studytype for this break) in the Headlines created by the "line" statement?

 

Thanks a lot for your Input.

 

Super User
Super User
Posts: 9,416

Re: Proc Report - add headline with values of order variable

Well, posting test data in the form of a datastep would be helpful as I am not typing that in. Two things jump to minds, though I can't test:

options byline;

Per: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000234737.htm

This should print each by group.

 

What about adding:

compute before studytype;
  line'';
line studytype; endcomp;

Otherwise as above, post some test data in a usable format. 

New Contributor
Posts: 2

Re: Proc Report - add headline with values of order variable

Sorry about the missing data - will keep that in mind for the next time Smiley Happy

 

"line studytpe" was the solution... So simple! It shows values instead of value labels, but I am pretty sure that I will find a solution for that on my own.

 

Thanks so much!

Super User
Super User
Posts: 9,416

Re: Proc Report - add headline with values of order variable

If its a format then maybe (again not tested):

compute before studytype;
  line'';  
line studytype myfmt.;
/* Or for character */
line studytpe $myfmt.; endcomp;

Obviously replace the myfmt with the actual name of your format. 

Super User
Posts: 10,689

Re: Proc Report - add headline with values of order variable

compute before studytype; line''; line @1 studytype $8. ; endcomp;
Ask a Question
Discussion stats
  • 4 replies
  • 86 views
  • 3 likes
  • 3 in conversation