<?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 Print column of charcter strings to different sheets in Excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338394#M77067</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please help me with the following scenario?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to Output an excel workbook with different sheets, by Printing the Character String (to first cell of a Excel sheet) from column(or variable) of SAS Dataset, followed by data from the particular row (Ex: 10th row) in the sheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7576i4D23032878B2D495/image-size/original?v=1.0&amp;amp;px=-1" alt="Description to Sheets.PNG" title="Description to Sheets.PNG" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Description column shown above, should be printed into respective sheets to Excel Workbook.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex: Rule_01 sheet should have "Description to print for Rule-1" text printed to the first cell of the sheet named Rule_01.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;Pavan.ch&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13525iA44A3AC090502B99/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Description to Sheets.PNG" title="Description to Sheets.PNG" /&gt;</description>
    <pubDate>Mon, 06 Mar 2017 10:03:52 GMT</pubDate>
    <dc:creator>pavan1</dc:creator>
    <dc:date>2017-03-06T10:03:52Z</dc:date>
    <item>
      <title>Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338394#M77067</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please help me with the following scenario?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to Output an excel workbook with different sheets, by Printing the Character String (to first cell of a Excel sheet) from column(or variable) of SAS Dataset, followed by data from the particular row (Ex: 10th row) in the sheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7576i4D23032878B2D495/image-size/original?v=1.0&amp;amp;px=-1" alt="Description to Sheets.PNG" title="Description to Sheets.PNG" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Description column shown above, should be printed into respective sheets to Excel Workbook.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex: Rule_01 sheet should have "Description to print for Rule-1" text printed to the first cell of the sheet named Rule_01.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;Pavan.ch&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13525iA44A3AC090502B99/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Description to Sheets.PNG" title="Description to Sheets.PNG" /&gt;</description>
      <pubDate>Mon, 06 Mar 2017 10:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338394#M77067</guid>
      <dc:creator>pavan1</dc:creator>
      <dc:date>2017-03-06T10:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338402#M77068</link>
      <description>&lt;P&gt;Something like (and this is just example):&lt;/P&gt;
&lt;PRE&gt;ods tagsets.excelxp file="c:\want.xml";

proc sort data=have (keep=rule) out=loop;
  by rule;
run;

data _null_;
  set loop;
  call execute('ods tagsets.excelxp options(sheet_name="'||strip(rule)||'";');
  call execute('proc print data=have; where rule="'||strip(rule)||'"; run;');
run;

ods tagsets.excelxp close;&lt;/PRE&gt;
&lt;P&gt;You could of course do a similar thing with libname excel, proc export etc., the real trick is in getting the loop dataset and have the data _null_ generate the required code.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 10:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338402#M77068</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-06T10:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338408#M77069</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code that i have used to make it more clear .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, user will give the input data to Excel, for which they want the report to be generated. which is attached before (Rule, Description). By taking the input from rule column (Index sheet) . I have queried the data from PL/SQL and Exporting the data of respective Rules to different sheets of the output.XLS, which i could do it successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now what i want is, to print the Description of the respective rule in 1st cell of the particular Rule while Exporting the data to Excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way that i could acess the Description from the Rules dataset, so as to get the output?&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;proc import datafile='M:\SAS\Rules_Input.xlsx' 
out=work.example dbms=EXCEL replace ;
sheet="Index" ;
range="A1:B100";
getnames=YES;
run;

data rules;
set example;
if missing(rule) then delete;
run;


proc sql noprint;
	select distinct rule into: rule_list separated by ' ' from work.rules;
quit;


%macro test;
%local i next_rule ;
%let i=1;
%do i=1 %to %sysfunc(countw(&amp;amp;rule_list));
	%let next_rule=%scan(&amp;amp;rule_list,&amp;amp;i);
		proc sql;
		connect to oracle as odbc(&amp;amp;srvr readbuff=1000);
		create table &amp;amp;next_rule as select * from connection to ODBC
		(
			select * from &amp;amp;next_rule
		);
		DISCONNECT FROM ODBC;
		QUIT;
		RUN;

	proc export  data=&amp;amp;next_rule  dbms=EXCEL REPLACE 
    outfile="M:\SAS\Output.xls"; 
    sheet=&amp;amp;next_rule;
  	run;
	%end;
%end;
%mend test;

%test;&lt;/PRE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 11:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338408#M77069</guid>
      <dc:creator>pavan1</dc:creator>
      <dc:date>2017-03-06T11:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338414#M77070</link>
      <description>&lt;P&gt;The easiest whay is to put the rule description as a title, and in the options of the tagsets.excel use embed_titles.&lt;/P&gt;
&lt;PRE&gt;ods tagsets.excelxp file="c:\want.xml" options(embedded_titles="yes");

proc sort data=have out=loop;
  by rule;
run;

data _null_;
  set loop;
  call execute('ods tagsets.excelxp options(sheet_name="'||strip(rule)||'";');&lt;BR /&gt;  call execute('title "'||strip(description)||'";');
  call execute('proc print data=have; where rule="'||strip(rule)||'"; run;');
run;

ods tagsets.excelxp close;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 11:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338414#M77070</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-06T11:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338430#M77071</link>
      <description>&lt;P&gt;Or a different structure where you create a Table of Contents on first sheet with hyperlinks to each sheet/rule.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TOC can be automated in TAGSETS.EXCELXP.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 12:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338430#M77071</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-06T12:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338432#M77072</link>
      <description>&lt;P&gt;Also, you can't go after the fact and export to a already created sheet/file in a specific cell. Are you on SAS 9.4? If do, using XLSX engine and RANGE could be an option. Or ODS Excel. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 12:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338432#M77072</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-06T12:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338488#M77082</link>
      <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im using SAS 9.3 and jus want to export both data and Description/Titles for the respective rules at the same time by looping.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 16:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338488#M77082</guid>
      <dc:creator>pavan1</dc:creator>
      <dc:date>2017-03-06T16:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338684#M77180</link>
      <description>&lt;P&gt;Hello RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods tagsets.excelxp file="c:\want.xml" options(embedded_titles="yes");

proc sort data=have out=loop;
  by rule;
run;

data _null_;
  set loop;
  call execute('ods tagsets.excelxp options(sheet_name="'||strip(rule)||'";');&lt;BR /&gt;  call execute('title "'||strip(description)||'";');
  call execute('proc print data=have; where rule="'||strip(rule)||'"; run;');
run;

ods tagsets.excelxp close;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Can you please give me the above example with proc export to excel ?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 05:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338684#M77180</guid>
      <dc:creator>pavan1</dc:creator>
      <dc:date>2017-03-07T05:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Print column of charcter strings to different sheets in Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338725#M77193</link>
      <description>&lt;P&gt;Why do you want to use export, that has no formatting functionality at all, not sure you can embed titles or anything like that. &amp;nbsp;Is it because you want an XLSX file (maybe use libname excel then if you have &amp;gt; 9.3). &amp;nbsp;I specifically used tagset to get this additional functionality. &amp;nbsp;To do it your way you will need to create a temporary dataset with no observations, and set labels as the data you want, then output that, not easy and I don't have time to mess around with such a thing. &amp;nbsp;If you have to do this which is "Excel" thinking and not SAS/Databasing, then dump your data out to CSV and use VBA to process it into the form you want, far simpler.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 09:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-column-of-charcter-strings-to-different-sheets-in-Excel/m-p/338725#M77193</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-07T09:14:10Z</dc:date>
    </item>
  </channel>
</rss>

