BookmarkSubscribeRSS Feed
meki77
Calcite | Level 5

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.

 

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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. 

meki77
Calcite | Level 5

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

 

"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!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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. 

Ksharp
Super User
compute before studytype; line''; line @1 studytype $8. ; endcomp;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1991 views
  • 3 likes
  • 3 in conversation