Learning SAS? Welcome to the exclusive online community for all SAS learners.

Want to split variable names in Proc Print with html output as in listing output

Reply
Contributor
Posts: 65

Want to split variable names in Proc Print with html output as in listing output

In Proc Print of a dataset, I want my variable names to split where the case changes in html output, as they do automatically in listing output. 

Example: I have StdzedMagniThresh at the top of a column, but I want

Stdzd
Magni

Thresh

 

Also, I want to suppress rolling over of a long text value in a Proc Print of a data set. 

Example: here is what I am getting for the value of the Label variable:

Effects of 2SD of

predictors:

but I want:

Effects of 2SD of predictors:

My patch for this problem is to rename the Label variable to something like ThisIsAlongerLabel (which, of course, I don't want to split!).

Naturally I have searched without success. Thanks.

 

Will

Super User
Super User
Posts: 7,401

Re: Want to split variable names in Proc Print with html output as in listing output

Actually, if your not specifying exactly where to put break points, then your letting whatever output destination/function it is your using guess where to put the breaks.  Now if I was using proc report there is an option called split='~' - you can put any character in rather than tilde.  Then in your labels you would put this same character to show where to break:

label="A~Long~Text~String";

You can do it in other methods as well, \n for RTF destinations, pretty sure HTML has a code for this also.  

The second part here is to setup the report as you want to see it, set column widths, formats etc.  As you haven't shown anything this is just an example:

proc report data=have nowd split='~';
  columns a b c;
  define a / "A~Long~Text~String" style={cellwidth=5cm};
run;
Contributor
Posts: 65

Re: Want to split variable names in Proc Print with html output as in listing output

Thanks for your prompt reply, but what you are suggesting requires more overhead work.  After 30 years of proc printing to the listing window where the variables split nicely and text-variable values do not split, now I have to put up with html output in the results window where the variables don't split and the values do!  I am hoping that buried in the documentation is some kind of control of the formatting that will give me html output like the listing output..

Super User
Super User
Posts: 7,401

Re: Want to split variable names in Proc Print with html output as in listing output

Well, you can always turn the HTML output off and switch back to listing.  Bit confused as your post says you have been using this for years, but posted in the Learning forum area, so which SAS software are you using.  For standard SAS just go up to Tools->Options->Preferences, then Results tab, check Listing and uncheck HTML.  

HTML is a different destination completely from listing - tag based, so you would need to look at the tagset how it is being created, check how HTML renders things etc.  

Contributor
Posts: 65

Re: Want to split variable names in Proc Print with html output as in listing output

I'm using SAS Studio/University Edition when introducing SAS to my students and colleagues. SAS Studio doesn't have a text-only listing window. The html is quite pretty in some respects, but in this case it's ugly.  I use the main SAS package for my own analyses or when I run analyses for others.  I don't use html output there, because the listing is so much faster to output and easier to annotate, search, and copy stuff..

Contributor
Posts: 65

Re: Want to split variable names in Proc Print with html output as in listing output

[ Edited ]

If you really like listing output, you can still generate it with SAS University Edition. It won't display automatically, but if you click on the output, SAS University Edition will open it.

 

Example code:

ods listing file='/folders/myfolders/SAS Communities/Example_listing.txt';

proc print data=sashelp.baseball;
  title 'SASHELP.BASEBALL data set';
run;

ods listing close;

The screen shot below shows the output.

ODS Listing output produced by SAS University EditionODS Listing output produced by SAS University Edition

 

Edited to add:   A thread on StackOverflow mentioned using the Monospace style with HTML output. See https://stackoverflow.com/questions/28310713/how-to-change-the-appearance-of-proc-print-output-in-sa... for more details.

 

The screen shot below shows HTML output using Monospace style.

ODS HTML output in SAS University Edition using Monospace styleODS HTML output in SAS University Edition using Monospace style

 

Contributor
Posts: 65

Re: Want to split variable names in Proc Print with html output as in listing output

Suzanne, sorry for the tardy action on your helpful post. I was overwhelmed with stuff and almost forgot that I saw a reply several weeks ago. Yes, it works, thank you. Now I have to see if I can get used to the additoinal hassle of opening and editing a txt file in Word that was much quicker via the old listing window. Also, sending stuff to the txt file doesn't stop it going to the Results window--not that I would want it to, but it can take ages to print to the Results window.  Sigh. 

 

Re the reference to StackOverflow. In SAS Studio I went to Preferences and chose Monospace.  Yeah, that produced 1960s line-printer style output, but it didn't split variable names at case-changes, and it ignored ls=whatever commands (although these were honored in the txt file, of course).  Anyway, thanks for trying.

 

Will

Contributor
Posts: 65

Re: Want to split variable names in Proc Print with html output as in listing output

Attached is an extreme example of the need to split variable names with Proc Print.


Capture.JPG
Super User
Posts: 10,500

Re: Want to split variable names in Proc Print with html output as in listing output

If you want to control the width of the displayed values then you need to specify a style override for the variable to set the cell width.

Note that setting the cell width will affect the width of the column header space and modify where the name would split.

 

I might suggest using a meaningful label and if you don't like where the heading splits use the SPLIT option to force the splits by adding that charcter to the label.

Contributor
Posts: 65

Re: Want to split variable names in Proc Print with html output as in listing output

Neither of your suggestions are ideal.  If I specify a style override on the column width (how?), the variable name will not generally split at the CaseChange.  Specifying labels that split at inserted characters is not really practical.  I just want the variables to split at the case change and values not to split, like in the good old listing window. Give me a listing window in SAS Studio and I will gladly revert to it.  This is a vote of no confidence in SAS's html Results window. It takes too long to build up, too.

Ask a Question
Discussion stats
  • 9 replies
  • 624 views
  • 2 likes
  • 4 in conversation