<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can i export data into excel with Comments in each cell? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/346959#M80054</link>
    <description>&lt;P&gt;No, not directly. &amp;nbsp;Personally, If I have to create an Excel file, with Excel specific functionality (and that would follow a lot of calls about why Excel isn't a good medium for data), then I would dump the data out to a plain Excel file, and have a macro in VBA which loads and processes the data using Office VBA. &amp;nbsp;Its very simple, most taks you can do and record to get the code.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2017 09:02:55 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-04-04T09:02:55Z</dc:date>
    <item>
      <title>Can i export data into excel with Comments in each cell?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/346942#M80048</link>
      <description>&lt;P&gt;Hi guys, I have a set of data containing the description, start date and end date in a table format, similar to excel. The previous developer set the data to export into excel file. However, my client wants to have comment box when hover to a particular cell in excel. May i know if this is possible? The comment box will display the secription in my data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need your advice.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 07:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/346942#M80048</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2017-04-04T07:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can i export data into excel with Comments in each cell?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/346959#M80054</link>
      <description>&lt;P&gt;No, not directly. &amp;nbsp;Personally, If I have to create an Excel file, with Excel specific functionality (and that would follow a lot of calls about why Excel isn't a good medium for data), then I would dump the data out to a plain Excel file, and have a macro in VBA which loads and processes the data using Office VBA. &amp;nbsp;Its very simple, most taks you can do and record to get the code.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 09:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/346959#M80054</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-04T09:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Can i export data into excel with Comments in each cell?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/347036#M80097</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can control a lot of things within SAS, comment boxes and highlights are possible, check this out:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ODS LISTING CLOSE;
ods TAGSETS.EXCELXP file="C:\TEMP\workbook.xml" style=statistical
                    options(frozen_headers='yes' sheet_interval='none' sheet_name="class" autofilter='1-8' autofit_height='yes');

proc report data=sashelp.class;
   columns age name sex height weight;
   define age    /display style=[just=l cellwidth=2.0cm tagattr='type:String format:0'];
   define name   /display style=[just=l cellwidth=2.0cm tagattr='type:String format:Text'];
   define sex    /display style=[just=l cellwidth=2.0cm tagattr='type:String format:Text'];
   define height /display style=[just=l cellwidth=2.0cm tagattr='type:String format:0'];
   define weight /display style=[just=l cellwidth=2.0cm tagattr='type:String format:0'];

   compute weight; 
      * Cell comment;  
      if      (weight/2)/(height*2.54/100)**2&amp;lt;18.5        then call define(_col_, "style", "style=[background=CXFFFF66 flyover='Underweight']");
      else if  18.5&amp;lt;=(weight/2)/(height*2.54/100)**2&amp;lt;25   then call define(_col_, "style", "style=[background=white flyover='healthy weight']");
      else if  (weight/2)/(height*2.54/100)**2&amp;gt;=25        then call define(_col_, "style", "style=[background=CXFFCC66 flyover='Overweight']");

   endcomp;
run;

ods tagsets.excelxp close;
ods listing;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;A way to convert back to native xlsx can be found here: &lt;A href="http://support.sas.com/kb/43/496.html" target="_self"&gt;http://support.sas.com/kb/43/496.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But in order to keep your comment on the cells you first need to convert the xml to xls and afterward the xls to xlsx. A very quick and even more dirty way to achieve this is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options noxwait xsync; /* cave: execute synchronously with SAS */&lt;BR /&gt;
%macro convertXML2Xls(default=);
%local ext;
%let ext=xml;
data _null_;
file "'&amp;amp;default\temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "  ExtName = fso.GetExtensionName(f)";
put "  Filename= fso.GetBaseName(f)";
put "    if ExtName=""&amp;amp;ext"" then";
put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
put "           xlapp.Visible = false";
put "           mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xls"", -4143";
put "    End If";
put "  Next";
put "  mybook.Close";
put "  xlapp.DisplayAlerts = True";
/* Removes original files */
/*put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";*/
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)"; 
run; 
 
x "cscript ""&amp;amp;default\temp.vbs""";

%mend;
%convertXML2Xls(default=c:\temp);

%macro convertXls2XlsX(default=);
%local ext;
%let ext=xls;
data _null_;
file "'&amp;amp;default\temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "  ExtName = fso.GetExtensionName(f)";
put "  Filename= fso.GetBaseName(f)";
put "    if ExtName=""&amp;amp;ext"" then";
put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
put "           xlapp.Visible = false";
put "           mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";
put "    End If";
put "  Next";
put "  mybook.Close";
put "  xlapp.DisplayAlerts = True";
/* Removes original files */
/*put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";*/
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)"; 
run; 
 
x "cscript ""&amp;amp;default\temp.vbs""";

%mend;
%convertXls2XlsX(default=c:\temp);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8149iF6862A3DC9C98EBA/image-size/medium?v=1.0&amp;amp;px=-1" alt="screenshot_35.png" title="screenshot_35.png" border="0" /&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 13:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/347036#M80097</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-04-04T13:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can i export data into excel with Comments in each cell?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/347050#M80101</link>
      <description>&lt;P&gt;Not with Proc Export. Proc Export is designed to be a bare-bones &lt;STRONG&gt;data&lt;/STRONG&gt; interchange. The report procedures allow adding additional bits as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;&amp;nbsp;demonstrates.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 14:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/347050#M80101</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-04T14:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can i export data into excel with Comments in each cell?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/441135#M110309</link>
      <description>&lt;P&gt;hi, if I add a variable flag_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data aaa;
set sashelp.class;
order=_n_;
if name="Barbara" then do;
flag_2="Y";
comment_2="Her name is Barbara";
end;
if name="Jane" then do;
flag_3="Y";
comment_3="Her Gender is Female";
end;
if name = "Carol" then flag_new="New";
flag_1="";
flag_4="";
flag_5="";
run;



proc report data=aaa;
columns age name sex height weight flag_2;
define age /display style=[just=l cellwidth=2.0cm tagattr='type:String format:0'];
define name /display style=[just=l cellwidth=2.0cm tagattr='type:String format:Text'];
define sex /display style=[just=l cellwidth=2.0cm tagattr='type:String format:Text'];
define height /display style=[just=l cellwidth=2.0cm tagattr='type:String format:0'];
define weight /display style=[just=l cellwidth=2.0cm tagattr='type:String format:0'];

define flag_2/noprint;

compute name; 
* Cell comment; 
if flag_2="Y" and name^="" then call define(_col_, "style", "style=[background=green flyover='Her name is Barbara']");
/*this code indicate that if the flag_2 is Yes, I will let the cell get the green color and add a comment "Her name is Barbara"*/
endcomp;
run;&lt;/PRE&gt;&lt;P&gt;why doesn't the code work? the cell for name="Barbara" DON'T get the green color&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 08:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/441135#M110309</guid>
      <dc:creator>XinxinWei</dc:creator>
      <dc:date>2018-03-01T08:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can i export data into excel with Comments in each cell?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/913136#M359923</link>
      <description>&lt;P&gt;Put flag_2 before name in the column statement.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 15:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-i-export-data-into-excel-with-Comments-in-each-cell/m-p/913136#M359923</guid>
      <dc:creator>KSASW</dc:creator>
      <dc:date>2024-01-26T15:37:25Z</dc:date>
    </item>
  </channel>
</rss>

