PROC Report

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

PROC Report

I use SAS 9.4. In the the Proc Report procedure I compute images which display in the report as follows (the code totals 400 lines):

 

compute image;

length imageloc $90;

image=' ';

if percbalchgYOY <=-.9851 then do; imageloc= catt('style={preimage="h:\_STUFF\icons\rdn99%.png"}'); end;

else if percbalchgYOY <=-.9751 then do; imageloc= catt('style={preimage="h:\_STUFF\icons\rdn98%.png"}'); end;

else if percbalchgYOY <=-.9651 then do; imageloc= catt('style={preimage="h:\_STUFF\icons\rdn97%.png"}'); end;

else if percbalchgYOY <=-.9551 then do; imageloc= catt('style={preimage="h:\_STUFF\icons\rdn96%.png"}'); end;

You can see that this is used on a sinlg variable - percbalchgYOY. I would like to create a macro or some other method to reuse this same code without recreating 400 lines of code for each variable separately.  


Accepted Solutions
Solution
‎02-26-2016 03:19 PM
Contributor
Posts: 28

Re: PROC Report

I'd prefer not to use pictures. I modeled the images off CNBC stock tickers..... they pop and succinctly illustrate the change (in my opinion). I already used background highlights, etc. but having the up/down and value is my goal.... its a preference for me in the way its illustrated,

 

Thank you for your help! I really appreciate it.

View solution in original post


All Replies
Super User
Super User
Posts: 7,720

Re: PROC Report

Sorry, not really following.  What does the output look like.  Had a brief look at the code, and it dosen't really make sense:

if percbalchgYOY <=-.9851 then do;

  imageloc=catt('style={preimage="h:\_STUFF\icons\rdn99%.png"}'); 

end;  

else if percbalchgYOY <=-.9751 then do;

  imageloc=catt('style={preimage="h:\_STUFF\icons\rdn98%.png"}'); 

end;     

else if percbalchgYOY <=-.9651 then do;

  imageloc=catt('style={preimage="h:\_STUFF\icons\rdn97%.png"}'); 

end;     

else if percbalchgYOY <=-.9551 then do;

  imageloc=catt('style={preimage="h:\_STUFF\icons\rdn96%.png"}'); 

end;

For example, the above code, what is the relation of the number/logic, e.g. <= 9651 to the filename of the png?  Why are you using % in the filename?  What is the difference between the rdn97 row and the rdn96 row, its same if logic?

 

Perosnally I would look at doing you logic in a datastep, then use that in the report, just at a rough example:

data inter;
  set have;
  do i=9851 to 9551 by -100;
    if percbalchgyoy <= i then pre_image=catt('style={preimage...);
  end;
run;

So instead of writing each if by hand, use a do loop to generate a string in the dataset.  Then use that string in your report.  Its hard to be specific as this seems a big process, and its hard to focus.  Try to provide a small example dataset, what the output should look like and a small subset of the logic.

Contributor
Posts: 28

Re: PROC Report

I attached 2 png output images. I am inserting these images in the percbalchgYOY column when the percent balance change is calculated as -98% and -99%, respectively. For rounding purposes I use 4 level decimal place (i.e. if percbalchgYOY <= 0.9865 then use 99%). I meticulously created these 400 images similar to the two attached because I did not see a way for SAS to create the arrow and the value combined. I also attached a small example and highlighted the relevant area in the code (sascommunityprocrpt2)

Super User
Posts: 19,167

Re: PROC Report

I don't see any attachments.

 

I highly agree with @RW9 solution of calculating this in a datastep prior to proc report. Especially since it seems you have some rules so you could make formulas rather than have 500 lines of code, or use a proc format to do the mapping. 

 

Depending on the image there may be other ways of getting what you want.

Contributor
Posts: 28

Re: PROC Report

Here are the images


rdn98%.PNGrdn99%.PNG
Contributor
Posts: 28

Re: PROC Report

I like the dataset suggestion - this will greatly reduce the lines of code. Can SAS create an image similar to the ones attached without my code having to grab the images from a shared drive? Even if its not exact (although I am a fan of whats here) - I am looking for an up/down indicator with a value combined in one cell,

Super User
Super User
Posts: 7,720

Re: PROC Report

Well, as a picture is an array of codes representing the RGB color for each pixel, you could in theory write code to create.  I wouldn't recommend it though, better to use a proper art package.  Why do you need to use pictures by the way?  I would generally avoid it myself, the reason being is if that information contained in the picture later on, you will need a manual process to extract it, or some funky text recognition.  I would always recommend keeping data as text, it just makes life easier.  I mean you can still color a cells background/foreground, font color and size etc. to make it stand out.

Solution
‎02-26-2016 03:19 PM
Contributor
Posts: 28

Re: PROC Report

I'd prefer not to use pictures. I modeled the images off CNBC stock tickers..... they pop and succinctly illustrate the change (in my opinion). I already used background highlights, etc. but having the up/down and value is my goal.... its a preference for me in the way its illustrated,

 

Thank you for your help! I really appreciate it.

Super User
Posts: 19,167

Re: PROC Report

You've marked the question answered, I'm assuming you found a solution. 

Contributor
Posts: 28

Re: PROC Report

Yes, I chose to ad a preimage with up/down images and keep the system calculated value. This works fine. Thank you

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 1346 views
  • 0 likes
  • 3 in conversation