<?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: macros problem in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3836#M1615</link>
    <description>Hi, &lt;BR /&gt;
  David is right. This does look like a homework problem. However, as a teacher, I am willing to offer the following suggestions:&lt;BR /&gt;
  &lt;BR /&gt;
1) have a working SAS program that reads one or more of the 12 monthly files using hard-coded input and output file names;&lt;BR /&gt;
  &lt;BR /&gt;
1a) After the program is working for 1 or 2 files, modify this program to read all 12 files (perhaps consider using a macro %do loop or the FILEVAR/FILENAME combination to read the 12 files)&lt;BR /&gt;
  &lt;BR /&gt;
2) have a working SAS program that reads the Product Info file using hard-coded input and output file names;&lt;BR /&gt;
  &lt;BR /&gt;
3) have a working SAS program that merges that output file from #1 with the Product file from #2 (decide whether you will use a merge or an sql join to get your resulting file)&lt;BR /&gt;
 &lt;BR /&gt;
4) At some point, in this process, use a where clause with hardcoded from and to dates to make sure that you can select the correct date range from either the file you create in #1 or as you do the merge or the join in #3. (I would probably include the where selection in the #3 program.&lt;BR /&gt;
  &lt;BR /&gt;
5) Now, go back and start to "macro-ize" the programs. Use &lt;B&gt;%let&lt;/B&gt; statements for setting values like the from and to dates. Depending on how you write the program for #1, you might consider using numbered macro variables for each monthly file.&lt;BR /&gt;
  &lt;BR /&gt;
6) After you have the "macro-ized" program working with hard-coded %LET statements, create a macro program or "set" of macro programs. Perhaps you would turn program #1 into a single macro program called %readdata -- you will probably set macro parameters that will take the place of the %LET statements. It is in this macro program that you will add any macro condition logic, like %IF or add %DO loops.&lt;BR /&gt;
  &lt;BR /&gt;
7) then you might combine programs #2 and #3 into another macro program called %seldata -- again you will probably set your macro parameters for from and to dates here.&lt;BR /&gt;
  &lt;BR /&gt;
8) Test your macro programs. This options statement will help you debug any errors you get:&lt;BR /&gt;
[pre]&lt;BR /&gt;
options mprint mlogic symbolgen;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
      &lt;BR /&gt;
Finally, continue refining your program until the final output is the output you want.&lt;BR /&gt;
Designing a macro program of this complexity is an iterative process. No matter what you do, you MUST have working SAS programs to start with. .&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
corrected %let in #5...thanks, david!   &lt;BR /&gt;
Message was edited by: Cynthia@sas</description>
    <pubDate>Thu, 19 Jul 2007 03:24:26 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2007-07-19T03:24:26Z</dc:date>
    <item>
      <title>macros problem</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3834#M1613</link>
      <description>Exercise:&lt;BR /&gt;
There are 12 Data Files (one for each Month) which contain data for Orders (Order Id, Product Id, Sales).There is a separate Data File for Product Referential which contains the Product Name, Feature, SKU Number.&lt;BR /&gt;
&lt;BR /&gt;
Write a SAS Program which reads these files and creates 12 SAS Datasets. There is probablity of Duplicate data and hence duplicate data based on orderid should be eliminated.&lt;BR /&gt;
&lt;BR /&gt;
Write a Macro which will take as input 2 parameters (FromMonth and ToMonth). It should merge the data from the FromMonth to ToMonth and then should summarise the results based on Quarters.&lt;BR /&gt;
&lt;BR /&gt;
Write another Macro which will merge the above created dataset with the Product Referntial and generate a ODS HtML Report for the summarised data for each product details and quater.</description>
      <pubDate>Wed, 18 Jul 2007 05:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3834#M1613</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-07-18T05:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: macros problem</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3835#M1614</link>
      <description>This looks very much like a homework problem, and you aren't likely to have people doing your homework for you.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Thu, 19 Jul 2007 01:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3835#M1614</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-07-19T01:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: macros problem</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3836#M1615</link>
      <description>Hi, &lt;BR /&gt;
  David is right. This does look like a homework problem. However, as a teacher, I am willing to offer the following suggestions:&lt;BR /&gt;
  &lt;BR /&gt;
1) have a working SAS program that reads one or more of the 12 monthly files using hard-coded input and output file names;&lt;BR /&gt;
  &lt;BR /&gt;
1a) After the program is working for 1 or 2 files, modify this program to read all 12 files (perhaps consider using a macro %do loop or the FILEVAR/FILENAME combination to read the 12 files)&lt;BR /&gt;
  &lt;BR /&gt;
2) have a working SAS program that reads the Product Info file using hard-coded input and output file names;&lt;BR /&gt;
  &lt;BR /&gt;
3) have a working SAS program that merges that output file from #1 with the Product file from #2 (decide whether you will use a merge or an sql join to get your resulting file)&lt;BR /&gt;
 &lt;BR /&gt;
4) At some point, in this process, use a where clause with hardcoded from and to dates to make sure that you can select the correct date range from either the file you create in #1 or as you do the merge or the join in #3. (I would probably include the where selection in the #3 program.&lt;BR /&gt;
  &lt;BR /&gt;
5) Now, go back and start to "macro-ize" the programs. Use &lt;B&gt;%let&lt;/B&gt; statements for setting values like the from and to dates. Depending on how you write the program for #1, you might consider using numbered macro variables for each monthly file.&lt;BR /&gt;
  &lt;BR /&gt;
6) After you have the "macro-ized" program working with hard-coded %LET statements, create a macro program or "set" of macro programs. Perhaps you would turn program #1 into a single macro program called %readdata -- you will probably set macro parameters that will take the place of the %LET statements. It is in this macro program that you will add any macro condition logic, like %IF or add %DO loops.&lt;BR /&gt;
  &lt;BR /&gt;
7) then you might combine programs #2 and #3 into another macro program called %seldata -- again you will probably set your macro parameters for from and to dates here.&lt;BR /&gt;
  &lt;BR /&gt;
8) Test your macro programs. This options statement will help you debug any errors you get:&lt;BR /&gt;
[pre]&lt;BR /&gt;
options mprint mlogic symbolgen;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
      &lt;BR /&gt;
Finally, continue refining your program until the final output is the output you want.&lt;BR /&gt;
Designing a macro program of this complexity is an iterative process. No matter what you do, you MUST have working SAS programs to start with. .&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
corrected %let in #5...thanks, david!   &lt;BR /&gt;
Message was edited by: Cynthia@sas</description>
      <pubDate>Thu, 19 Jul 2007 03:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3836#M1615</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-07-19T03:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: macros problem</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3837#M1616</link>
      <description>Well put Cynthia, now Vasu is still left with actually doing the work and learning how to do it.&lt;BR /&gt;
&lt;BR /&gt;
I will clarify though that in your point number 5, I'm sure you meant to write "%Let", not "&amp;amp;Let" for the macro symbol assignments.  Since you used %Let in number 6, it was clearly a littoral that you would have picked up when you ran the code as you gradually built up the solution from tested and working SAS code.  (That's a great message that is worthy of repetition, and might almost make it on the 10 rules of good SAS programming.)&lt;BR /&gt;
&lt;BR /&gt;
I hope the homework reflects the support provided.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Incidentally, Chris H commented on my posting the 1000th message on the forums a while back, but I see that on your own your postings are currently more than half that figure.  That's a very big contribution, and I see well deserved comments reflecting appreciation for your work.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Thu, 19 Jul 2007 08:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/macros-problem/m-p/3837#M1616</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-07-19T08:35:59Z</dc:date>
    </item>
  </channel>
</rss>

