<?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: Macro to create excel report for mulit-year file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169350#M32484</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your answer. I'm trying to run your program but when I'm running the "proc means" statements I'm getting the "ERROR: Variable value in list does not match type prescribed for the list".&lt;/P&gt;&lt;P&gt;I should have probably mentioned that most of my variables are character type. The tables that I attached were just to present the general outline of my datasets - I have many of them, all in SAS view format, that's why I thought about creating a macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a beginner in SAS programming, I would appreciate any tips how to solve that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regard,&lt;/P&gt;&lt;P&gt;Alicja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Feb 2015 15:45:03 GMT</pubDate>
    <dc:creator>AlicjaJ</dc:creator>
    <dc:date>2015-02-16T15:45:03Z</dc:date>
    <item>
      <title>Macro to create excel report for mulit-year file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169347#M32481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to create a macro which would produce the % of missing values for each variable in each year.&lt;/P&gt;&lt;P&gt;I'm using SAS 9.2. My datasets are in SAS view format and the sample looks less like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="108" style="border: 1px solid #000000; width: 1158px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;P&gt;&lt;STRONG&gt;year&lt;/STRONG&gt;&lt;/P&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;V2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;V3&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;V4&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1998&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1998&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;23123&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2000&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My desired excel output would look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="161" style="border: 1px solid #000000; width: 945px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Header 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;1998&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;1999&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;2000&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;V2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;50%&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;66,6%&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;V3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;V4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would highly appreciate any help.&lt;/P&gt;&lt;P&gt;Have a nice weekend!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 17:13:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169347#M32481</guid>
      <dc:creator>AlicjaJ</dc:creator>
      <dc:date>2015-02-14T17:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create excel report for mulit-year file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169348#M32482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't need a macro. It would be a bit easier if you had SAS 9.3 because then you wouldn't need to transpose the data. I'm also not sure the IDLABEL statement is available for proc transpose in SAS 9.2 but you can remove that line without a major impact to your results. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's one way, without a macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards truncover;&lt;/P&gt;&lt;P&gt;input &lt;/P&gt;&lt;P&gt;year V2 V3 V4;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1998&lt;/P&gt;&lt;P&gt;1998 20&lt;/P&gt;&lt;P&gt;1999 . 30&amp;nbsp; &lt;/P&gt;&lt;P&gt;1999 . .&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1999 231 23&lt;/P&gt;&lt;P&gt;2000 . 25 &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data havet;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array v(3) v2-v4;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i=1 to dim(v);&lt;/P&gt;&lt;P&gt;&amp;nbsp; value=v(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; vart=vname(v(i));&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop v2-v4 i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=havet noprint;&lt;/P&gt;&lt;P&gt;class year vart;&lt;/P&gt;&lt;P&gt;types year*vart;&lt;/P&gt;&lt;P&gt;var value;&lt;/P&gt;&lt;P&gt;output out=want1 n=N nmiss=Nmiss;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want2;&lt;/P&gt;&lt;P&gt;set want2;&lt;/P&gt;&lt;P&gt;pct_miss=nmiss/(n+nmiss);&lt;/P&gt;&lt;P&gt;format pct_miss percent8.1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=want2;&lt;/P&gt;&lt;P&gt;by variable year;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=want2 out=want3(drop=_name_) Prefix=Year;&lt;/P&gt;&lt;P&gt;by variable;&lt;/P&gt;&lt;P&gt;id year;&lt;/P&gt;&lt;P&gt;idlabel year;&lt;/P&gt;&lt;P&gt;var pct_miss;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Percent Missing, By Year';&lt;/P&gt;&lt;P&gt;proc print data=want3 noobs label;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;title;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 18:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169348#M32482</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-02-14T18:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create excel report for mulit-year file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169349#M32483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data have;
infile cards truncover;
input
year V2 V3 V4;
cards;
1998
1998 20
1999 . 30 
1999 . .&amp;nbsp; 
1999 231 23
2000 . 25
;
run;
proc sql;
 select cat('nmiss(',strip(name),')/count(*) as ',strip(name)) into : list separated by ','
&amp;nbsp; from dictionary.columns
&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='HAVE' and name ne 'year';
 create table temp as
&amp;nbsp; select year,&amp;amp;list 
&amp;nbsp;&amp;nbsp; from have
&amp;nbsp;&amp;nbsp;&amp;nbsp; group by year;
quit;
proc transpose data=temp out=want;
id year;
run;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Feb 2015 04:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169349#M32483</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-02-15T04:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create excel report for mulit-year file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169350#M32484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your answer. I'm trying to run your program but when I'm running the "proc means" statements I'm getting the "ERROR: Variable value in list does not match type prescribed for the list".&lt;/P&gt;&lt;P&gt;I should have probably mentioned that most of my variables are character type. The tables that I attached were just to present the general outline of my datasets - I have many of them, all in SAS view format, that's why I thought about creating a macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a beginner in SAS programming, I would appreciate any tips how to solve that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regard,&lt;/P&gt;&lt;P&gt;Alicja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Feb 2015 15:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169350#M32484</guid>
      <dc:creator>AlicjaJ</dc:creator>
      <dc:date>2015-02-16T15:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create excel report for mulit-year file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169351#M32485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a macro that does it for a full dataset, not by groups.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/c3a9ddcb002c469e9d61" title="https://gist.github.com/statgeek/c3a9ddcb002c469e9d61"&gt;SAS - Missing Macro - For a dataset, variable level report the number of missing and non-missing observations&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Feb 2015 17:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-excel-report-for-mulit-year-file/m-p/169351#M32485</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-02-16T17:52:02Z</dc:date>
    </item>
  </channel>
</rss>

