<?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: How to use macro values to judge and append the datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-values-to-judge-and-append-the-datasets/m-p/426173#M104991</link>
    <description>&lt;P&gt;&lt;SPAN&gt;you don't need double quotes&amp;nbsp; here %if &amp;amp;report="Cumulative"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%if &amp;amp;report=Cumulative&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2018 17:30:36 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-01-09T17:30:36Z</dc:date>
    <item>
      <title>How to use macro values to judge and append the datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-values-to-judge-and-append-the-datasets/m-p/426171#M104990</link>
      <description>&lt;P&gt;Hello SAS guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I import multiply datasets into SAS. I want my datasets group by monthly and cumulative. If I want my reports generated both monthly and cumulative, how do I code?&lt;/P&gt;&lt;P&gt;Here is the sample codes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let report=Cumulative;&lt;/P&gt;&lt;P&gt;filename indata pipe "dir &amp;amp;datadir. /b";&lt;/P&gt;&lt;P&gt;data file_list;&lt;BR /&gt;length fname$ 256.;&lt;BR /&gt;infile indata truncover; /* infile statement for file names */&lt;BR /&gt;input fname$ 256.; /* read the file names from the directory */&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Proc sql noprint;&lt;BR /&gt;create table filename as&lt;BR /&gt;select fname from file_list where fname contains ".txt";&lt;BR /&gt;select count(DISTINCT fname) into :num_files from filename;&lt;BR /&gt;select distinct fname into :filein1 - :filein%left(&amp;amp;num_files) from filename;&lt;BR /&gt;create table name as&lt;BR /&gt;select compress( scan(fname,1,"."),"&amp;amp;","i" )as fname from filename;&lt;BR /&gt;select compress(fname," 12345abced","kis")into :name1 - :name%left(&amp;amp;num_files)&lt;BR /&gt;from name;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%macro fileread;&lt;BR /&gt;%do j=1 %to &amp;amp;num_files;&lt;BR /&gt;proc import datafile="&amp;amp;datadir.\&amp;amp;&amp;amp;filein&amp;amp;j." out=&amp;amp;&amp;amp;name&amp;amp;j. dbms=csv replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;datarow=2;&lt;BR /&gt;guessingrows=32767;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend fileread;&lt;BR /&gt;%fileread;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Now I import three monthly data into SAS. */&lt;/P&gt;&lt;P&gt;%macro outdata;&lt;/P&gt;&lt;P&gt;%if &amp;amp;report="Cumulative" %then %do;&lt;/P&gt;&lt;P&gt;data cdata;&lt;/P&gt;&lt;P&gt;set data10 - data12;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %do;&lt;/P&gt;&lt;P&gt;data cdata;&lt;/P&gt;&lt;P&gt;set data12;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%outdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it seems that SAS ignore the&amp;nbsp;condition: &amp;amp;report="Cumulative".&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 17:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-values-to-judge-and-append-the-datasets/m-p/426171#M104990</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2018-01-09T17:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macro values to judge and append the datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-values-to-judge-and-append-the-datasets/m-p/426173#M104991</link>
      <description>&lt;P&gt;&lt;SPAN&gt;you don't need double quotes&amp;nbsp; here %if &amp;amp;report="Cumulative"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%if &amp;amp;report=Cumulative&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 17:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-macro-values-to-judge-and-append-the-datasets/m-p/426173#M104991</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-09T17:30:36Z</dc:date>
    </item>
  </channel>
</rss>

