<?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: Will this code give me an expected result? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553859#M9421</link>
    <description>There are basic features missing that prevent you from even testing the code.&lt;BR /&gt;&lt;BR /&gt;Where is the %mend statement to finish the definition of %accountreport?&lt;BR /&gt;&lt;BR /&gt;Where is %accountreport being executed?&lt;BR /&gt;&lt;BR /&gt;How can this statement possibly finish the definition of %dsn:&lt;BR /&gt;&lt;BR /&gt;%mend sat;</description>
    <pubDate>Thu, 25 Apr 2019 05:54:06 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-04-25T05:54:06Z</dc:date>
    <item>
      <title>Will this code give me an expected result?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553833#M9419</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mlogic;

%macro accountreport (State=,Age=,Last_Tran_Date=);
%let title=Detail Listing of Account;
data profile3;
set myprj2.profile2 (keep=Acct_ID Name Birthday State Balance Last_Tran_Date);
/*Age=((int(today()-birthday)/365.25));*/
Age=intck('Year',birthday,today());
/*birthdate=input(birthday,mmddyy10.);*/

format Last_Tran_Date year4.
		Age 3.0
		Birthday best.;/*stored in numeric format*/
run;
options symbolgen mprint;
%macro dsn(title=, vars= );

proc report data=profile3;
	title "&amp;amp;title";
	column Acct_ID Name Balance Last_Tran_Date;
	define Acct_ID / display;
	define Name / display;
	define Balance / analysis sum;
	define Last_Tran_Date / display;
	rbreak after / summarize;
run;
%mend sat;

options mprint;
%dsn (vars=Acct_ID Name Balance Last_Tran_Date);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to create a report based on this format.Will this code work ?I am not sure how the title and the row followed by title will be achieved&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="expected_result.jpg" style="width: 562px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29018i324DFB25718EBE3A/image-size/large?v=v2&amp;amp;px=999" role="button" title="expected_result.jpg" alt="expected_result.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 02:41:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553833#M9419</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-25T02:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Will this code give me an expected result?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553854#M9420</link>
      <description>&lt;P&gt;Please post example data in a usable form (data step with datalines, see my footnotes). Excel files cannot give accurate information about SAS datasets (contents, type, lengths, formats), and many corporate sites block their download for security reasons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know if code works, follow Maxim 4. &lt;EM&gt;Try it&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 05:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553854#M9420</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-25T05:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Will this code give me an expected result?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553859#M9421</link>
      <description>There are basic features missing that prevent you from even testing the code.&lt;BR /&gt;&lt;BR /&gt;Where is the %mend statement to finish the definition of %accountreport?&lt;BR /&gt;&lt;BR /&gt;Where is %accountreport being executed?&lt;BR /&gt;&lt;BR /&gt;How can this statement possibly finish the definition of %dsn:&lt;BR /&gt;&lt;BR /&gt;%mend sat;</description>
      <pubDate>Thu, 25 Apr 2019 05:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553859#M9421</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-25T05:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Will this code give me an expected result?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553972#M9429</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn;
infile datalines missover dsd;
length Acct_ID 4 Name$ 7 Birthday 8 Sex$ 3 State$ 3 Cust_Type$ 7 Product$ 9 Balance 4 Last_Tran_Date 8; 
input Acct_ID 1-4 Name $ 6-11 Birthday mmddyy10. Sex $ 21-23  State $ 24-26 Cust_Type $ 28-33 Product $ 35-43 Balance 4. Last_Tran_Date mmddyy12.;
datalines;
1001 John   1/1/1962  M CA Gold   Checking 1000  9/1/2015
1002 Mary   2/1/1972  F CA Silver Saving   2000  10/1/2015
1003 Peter  3/1/1982  M NY Gold   Loan     3000  10/3/2016
1004 mary   4/1/1992  F NY Silver Checking 4000  9/17/2016
1005 Linda  5/1/1994  F WA Gold   Saving   5000  
1006 Susan  6/1/1997  F WA Gold   Loan     1000  9/15/2016
1007 Sam    7/1/1999  M CA Gold   Checking 2000  2/1/2016
1008 Thomas 8/1/1962  M CA Silver Checking 3000  7/1/2016
1009 Linda  9/1/1982  F NY Silver Saving   4000
;
run;
proc print data=dsn;
format last_Tran_Date year4.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is my data in datalinesMy expected result in the format is attached above.my code which is working but expecting in the format&lt;/P&gt;&lt;PRE&gt;options symbolgen mprint;&lt;BR /&gt;%macro dsn(title=, vars= );&lt;BR /&gt;&lt;BR /&gt;proc report data=profile3;&lt;BR /&gt;	title "&amp;amp;title";&lt;BR /&gt;	column Acct_ID Name Balance Last_Tran_Date;&lt;BR /&gt;	define Acct_ID / display;&lt;BR /&gt;	define Name / display;&lt;BR /&gt;	define Balance / analysis sum;&lt;BR /&gt;	define Last_Tran_Date / display;&lt;BR /&gt;	rbreak after / summarize;&lt;BR /&gt;run;&lt;BR /&gt;%mend dsn;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="expected_result.jpg" style="width: 562px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29033i0033740318201EAE/image-size/large?v=v2&amp;amp;px=999" role="button" title="expected_result.jpg" alt="expected_result.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 14:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553972#M9429</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-25T14:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Will this code give me an expected result?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553982#M9430</link>
      <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 14:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553982#M9430</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-25T14:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Will this code give me an expected result?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553995#M9431</link>
      <description>&lt;P&gt;It looks like you've left out a number of requirements/aspects of the data and your objective, but let me see if I can infer some.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have this transaction data.&amp;nbsp; You want to create&amp;nbsp;&lt;STRONG&gt;multiple&lt;/STRONG&gt; tables of output, separated by age range and by transaction year and maybe by US state.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your approach of using SAS macro language may be complicating things.&amp;nbsp; I'd first try to achieve this by using BY groups -- built into most SAS procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You didn't include US state fields in your data sample, so leaving that off for now.&amp;nbsp; To implement groups segmented by Age range (instead of discrete ages), you need to define another variable or use a SAS format.&amp;nbsp; Here's an example with your data that defines an "age level" format -- two levels, one for under 40 and one for over 40.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn;
infile datalines missover dsd;
length Acct_ID 4 Name$ 7 Birthday 8 Sex$ 3 State$ 3 Cust_Type$ 7 Product$ 9 Balance 4 Last_Tran_Date 8; 
input Acct_ID 1-4 Name $ 6-11 Birthday mmddyy10. Sex $ 21-23  State $ 24-26 Cust_Type $ 28-33 Product $ 35-43 Balance 4. Last_Tran_Date mmddyy12.;
Age=intck('Year',birthday,today());
format Last_Tran_Date year4.
		Age 3.0
		Birthday best.;/*stored in numeric format*/
datalines;
1001 John   1/1/1962  M CA Gold   Checking 1000  9/1/2015
1002 Mary   2/1/1972  F CA Silver Saving   2000  10/1/2015
1003 Peter  3/1/1982  M NY Gold   Loan     3000  10/3/2016
1004 mary   4/1/1992  F NY Silver Checking 4000  9/17/2016
1005 Linda  5/1/1994  F WA Gold   Saving   5000  
1006 Susan  6/1/1997  F WA Gold   Loan     1000  9/15/2016
1007 Sam    7/1/1999  M CA Gold   Checking 2000  2/1/2016
1008 Thomas 8/1/1962  M CA Silver Checking 3000  7/1/2016
1009 Linda  9/1/1982  F NY Silver Saving   4000
;
run;

proc format lib=work;
 value agelvl 0-39="&amp;lt; 40"
              40-high = "&amp;gt;= 40";
run;

proc sort data=dsn
 out=sorted;
 by age;
run;

proc report data=sorted;
	title "Detail Listing of Account";
  by age;
  format age agelvl.;
  label age="Age range";
	column Acct_ID Name Balance Last_Tran_Date;
	define Acct_ID / display;
	define Name / display;
	define Balance / analysis sum;
	define Last_Tran_Date / display;
	rbreak after / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example.jpg" style="width: 303px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29037i0169713EB9EA1468/image-size/large?v=v2&amp;amp;px=999" role="button" title="example.jpg" alt="example.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This needs more work, obviously.&amp;nbsp; But my advice (consistent with what others have said) -- get things working&amp;nbsp;&lt;STRONG&gt;without&lt;/STRONG&gt; macro first.&amp;nbsp; Maybe avoid macro language altogether and leverage the BY group capabilities in SAS procedures.&amp;nbsp; SAS macro is powerful, but once you introduce it to your program, your program becomes that much more difficult to maintain and debug.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 15:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Will-this-code-give-me-an-expected-result/m-p/553995#M9431</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2019-04-25T15:06:53Z</dc:date>
    </item>
  </channel>
</rss>

