BookmarkSubscribeRSS Feed
mikersas
Obsidian | Level 7

I thought this code would change the font color of a fieldf based on the value of another field in the columns:

compute id_rssd;

    if changed_event = '0' then do;

        call define (_col_, 'style', 'style=[foreground=blue]');

    end;

    if changed_event = '1' then do;

        call define (_col_, 'style', 'style=[foreground=green]');

    end;

endcomp;

But it didn't do anything.  The text came out black.

6 REPLIES 6
Ksharp
Super User

Because id_rssd is before changed_event in COLUMN,  you can't ask change something behind id_rssd when you compute id_rssd .so change compute name .

compute changed_event;

    if changed_event = '0' then do;

        call define (_col_, 'style', 'style=[foreground=blue]');

    end;

    if changed_event = '1' then do;

        call define (_col_, 'style', 'style=[foreground=green]');

    end;

endcomp;

And better post questions about proc report at ODS and Base Reporting  later on. Cynthia will give you professional service .

Xia Keshan

mikersas
Obsidian | Level 7

No improvement.

I also tried the following but it didn't help either:

Let me better explain what I'm trying to do:

I've got to define a display field to point to a url (this is working).

compute rssd_url;

     call define ('id_rssd','url',rssd_url);

endcomp;

I then need to change the color of the text based on the value of another field (which is not working):

compute id_rssd;

     If changed_event = '0' then do:

          call define (_col_, 'style', 'style=[foreground=blue]');

     end;

     If changed_event = '1' then do;

          call define (_col_, 'style', 'style=[foreground=green]');

     end;

endcomp;

Ksharp
Super User

Then post some sample data and code as short as you can , so I can test if it is worked.

Cynthia_sas
SAS Super FREQ

Hi:

  It is not entirely clear to me what you want to do. It seems that you want to do 2 things in 1 cell -- make the cell contents a clickable hyperlink and change the color of the text in the cell. But, depending on the destination, you may not be able to change the color of URL text. URL hyperlinks are generally set off from "regular" text in some way, like this: http://www.sas.com -- note how most of my text is black but the hyperlink is colored blue. Once you designate some text as a hyperlink, it takes on the hyperlink characteristics. I do not believe you can change the color. You might check with Tech Support, though. For HTML-based destinations, there are some style attributes LINKCOLOR and VISITEDLINKCOLOR that I believe will work to change the color of hyperlink/URL text, but I notice that you are not creating HTML output, so I don't think that LINKCOLOR will work with TAGSETS.EXCELXP -- but that is a question for Tech Support.

cynthia

mikersas
Obsidian | Level 7

It works if changed_event is placed before id_rssd in the columns statement and if you do it all in one compute statement:

CorrectCompute.jpg

Cynthia_sas
SAS Super FREQ

Hi:

  That makes sense. CHANGED_EVENT would have to appear before ID_RSSD in the column statement for the COMPUTE block to work. PROC REPORT works on a left-to-right basis and it only generates 1 report row at a time, one column at a time. So if you have this COLUMN statement:

column name age height weight;


          Then, based on how PROC REPORT works, in a COMPUTE block for NAME, you could NOT test AGE. That's because at the point in time when PROC REPORT is writing NAME to the report row, it has not yet written AGE. So AGE is technically NOT available to be tested.
     

  But if you had this COLUMN statement:

column age name height weight;
     

  Then, you COULD test AGE in the COMPUTE block for NAME because at the point in time when NAME is being handled, the value for AGE has already been put on the report row. PROC REPORT does NOT have a "program data vector" like a DATA step program, so there is only visibility of what has been placed on the report row, working from left to right, based on the COLUMN statement order of variables.


         This is something about PROC REPORT that is explained in the documentation and in our Report Writing class. The relevant documentation topics are: "Concepts: REPORT Procedure"
and "How Proc Report Builds A Report" -- you should be able to find them for your version of SAS by searching on the support.sas.com web site.  

       

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 9452 views
  • 0 likes
  • 3 in conversation