BookmarkSubscribeRSS Feed
sah_biostat
Fluorite | Level 6

Hello Team,

 

I have a sas dataset which contains all the ADaM datasets atrributes.I would like to export this dataset to excel.Is there any option to get the output with specific colours to differentiate the different datasets?

 

sah_biostat_0-1677595859537.png

If you see above screenshot my desired output should show all the adae information into one colour and all the admh into one colour.Are there any options ?

 

ods excel file="xxxx.xlsx";
proc print data=final noobs;
run;
ods excel close;

Please kindly help.

6 REPLIES 6
PaigeMiller
Diamond | Level 26
proc report data=yourdataset;
    columns variable1 variable2;
    compute variable1;
        if variable1='ADAE' then call define(_row_,'style','style={background=lightyellow}');
        else if variable1='ADMH' then call define(_row_,'style','style={background=lightmoderategreen}');
    endcompute;
run;


From now on, do NOT provide data as screen captures. We cannot program from screen captures. We need data as working SAS data step code (instructions), not screen captures or file attachments. In addition, in your screen capture, you didn't even show us the variable names, hence I use VARIABLE1 and VARIABLE2 as variable names, which you can fix.

--
Paige Miller
sah_biostat
Fluorite | Level 6

Hello @PaigeMiller ,

 

Thanks for the quick response.

 

Actually, I have datasets, variable, length, label as the variable names. I have many datasets in the datasets column .I cannot give style option manually. So, I am looking for any default options which i can put inside the macro.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PaigeMiller
Diamond | Level 26

@sah_biostat wrote:

 

Actually, I have datasets, variable, length, label as the variable names. I have many datasets in the datasets column .I cannot give style option manually. So, I am looking for any default options which i can put inside the macro.


How many different datasets are there? How many different colors do you need? What do you mean by "bi-coloring"? Can you provide example data (in the format I mentioned above)?


Also, you did not mention a macro in your original message. What do you want a macro to do?

--
Paige Miller
sah_biostat
Fluorite | Level 6

@PaigeMiller 

I have 15 +datasets in the dataset column.

sah_biostat_0-1677604991793.pngBi -colouring means just two colours simultaneously to differentiate the datasets visually. For instance, the first adam dataset is in grey, the second in white and repeating. Here, macro means this is for one study and I would like to apply this for every study so,we cannot fix dataset number(every study varies).For instance,leave macro topic. If we get solution for one study also fine.Looking for the options to get the output in desired way.

Sorry for attaching the screenshot I am unable to explain you clearly without the image.  

PaigeMiller
Diamond | Level 26

I realize that you are new here, but I have previously said I cannot work from data in screen captures. Data must be in the form of working SAS data step code, which you can type in yourself or follow the instructions I gave. Data cannot be in the form of file attachments or screen captures.

 

This is untested code, as I don't have data to test it on.

 

 

proc sort data=have;
    by impacted_adam;
run;
data temporary;
    set have;
    by impacted_adam;
    if first.impacted_adam then group+1;
run;
proc report data=temporary;
    columns group impacted_adam variable ... ;
    define group/noprint;
    compute variable1;
        if mod(group,2)=1 then call define(_row_,'style','style={background=lightgrey}');
        else call define(_row_,'style','style={background=lightmoderateyellow}');
    endcompute;
run;

 

 

--
Paige Miller
Cynthia_sas
SAS Super FREQ

Hi:

  One way around having to specify values in the COMPUTE block is to use a user-defined format, as shown here:

Cynthia_sas_0-1677608062127.png

 

  I based the format on the first character of the name field in the SASHELP.CLASS file. The variable I created was called ALFA. Your format would have the dataset names and the colors you choose. I picked 4 colors. You could pick 2 different colors. In the PROC REPORT code, the ALFA column is a NOPRINT column, so it is available to be used, but does not display on the report. This kind of trafficlighting should also work in ODS EXCEL. Without any example data, it is hard to do more than make general suggestions.

 

Cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 323 views
  • 0 likes
  • 3 in conversation