<?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 sas code to make a table like this... (urgent！） in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142363#M28545</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The sample data you're using illustrates why you shouldn't code "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt; line-height: 1.5em; background-color: #ffffff;"&gt;else do; &lt;/SPAN&gt;flag = 'last week' ; end;" but should calculate "last week" and then eventually have an other case like "else flag='earlier weeks'&amp;nbsp; "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below a code sample based on your code but using a format instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fmt_source;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format start date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length label $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain fmtname 'WeekGroup';&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain type 'N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do start=intnx('year',today(),-1) to today();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week=intck('week',start,today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select(week);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(0)&amp;nbsp;&amp;nbsp; label='This Week';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(1)&amp;nbsp;&amp;nbsp; label='Last Week';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise label=catx(' ',week,'weeks ago');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=fmt_source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data src_rec;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input name $ sex $ school $ dt date9. score;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;AAA F Law 9-sep-14 10&lt;/P&gt;&lt;P&gt;BBB F IT 10-Aug-14 20&lt;/P&gt;&lt;P&gt;CCC M Law 19-Sep-14 30&lt;/P&gt;&lt;P&gt;DDD F Art 10-Dec-14 25&lt;/P&gt;&lt;P&gt;EEE F Law 9-sep-14 40&lt;/P&gt;&lt;P&gt;FFF M Biz 10-Aug-14 45&lt;/P&gt;&lt;P&gt;GGG F Law 9-Dec-14 55&lt;/P&gt;&lt;P&gt;HHH M IT&amp;nbsp; 6-Dec-14 50&lt;/P&gt;&lt;P&gt;III M Law 19-Nov-14 45&lt;/P&gt;&lt;P&gt;JJJ M Art 10-Aug-14 20&lt;/P&gt;&lt;P&gt;kkk F Law 9-Dec-14 25&lt;/P&gt;&lt;P&gt;lll F Biz 8-Dec-14 20&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;proc tabulate data = src_rec order=unformatted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class school sex dt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var score;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format dt WeekGroup.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; table (school*sex ),dt='No of student Registered'*n=''(dt='Sum of score'*score=''*sum='')(dt='Avg of score'*score=''*mean='');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Dec 2014 11:43:14 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-12-10T11:43:14Z</dc:date>
    <item>
      <title>How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142355#M28537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to SAS programming and have tried a lot of times try to convert the table on the left to the right one use sas code....Could anyone help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the source table. If today is Monday, then the code will run to convert the source table into the output table.The blank of the output table is the No. of student registered that week. The week start from Sunday. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Source Table.jpg" class="jive-image" src="https://communities.sas.com/legacyfs/online/8292_Source Table.jpg" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;IMG alt="Output Table.jpg" class="jive-image" src="https://communities.sas.com/legacyfs/online/8293_Output Table.jpg" /&gt;&lt;/P&gt;&lt;P&gt;Really thank you very much !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 07:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142355#M28537</guid>
      <dc:creator>AmberForever</dc:creator>
      <dc:date>2014-12-09T07:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142356#M28538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc tabulate &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 08:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142356#M28538</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-12-09T08:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142357#M28539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So what's the question? How to create the table in general (Proc Tabulate) or how to get the grouping into "This Week" and "Last Week" or something else?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;O.K. - let's assume your problem is the week grouping. What you could do is to dynamically create a format and then use this format on source variable "date" in the Proc Tabulate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below the code to create the format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fmt_source;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format start date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length label $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain fmtname 'WeekGroup';&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain type 'N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do start=today()-100 to today();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week=intck('week',start,today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select(week);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(0)&amp;nbsp;&amp;nbsp; label='This Week';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(1)&amp;nbsp;&amp;nbsp; label='Last Week';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise label=catx(' ',week,'weeks ago');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=fmt_source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/** and here PROC TABULATE DATA=SOURCE.... **/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* test the format */&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date=today();&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date WeekGroup.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date=today()-8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date WeekGroup.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date=today()-40;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date WeekGroup.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 08:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142357#M28539</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-12-09T08:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142358#M28540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions is how to create the table, as well as the weekly grouping....&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 09:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142358#M28540</guid>
      <dc:creator>AmberForever</dc:creator>
      <dc:date>2014-12-09T09:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142359#M28541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data src_rec;&lt;/P&gt;&lt;P&gt;input name $ sex $ school $ dt date9.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;AAA F Law 9-sep-14&lt;/P&gt;&lt;P&gt;BBB F IT 10-Aug-14&lt;/P&gt;&lt;P&gt;CCC M Law 19-Sep-14&lt;/P&gt;&lt;P&gt;DDD F Art 10-Dec-14&lt;/P&gt;&lt;P&gt;EEE F Law 9-sep-14&lt;/P&gt;&lt;P&gt;FFF M Biz 10-Aug-14&lt;/P&gt;&lt;P&gt;GGG F Law 9-Dec-14&lt;/P&gt;&lt;P&gt;HHH M IT&amp;nbsp; 6-Dec-14&lt;/P&gt;&lt;P&gt;III M Law 19-Nov-14&lt;/P&gt;&lt;P&gt;JJJ M Art 10-Aug-14&lt;/P&gt;&lt;P&gt;kkk F Law 9-Dec-14&lt;/P&gt;&lt;P&gt;lll F Biz 8-Dec-14&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 date_flg ;&lt;/P&gt;&lt;P&gt;set src_rec;&amp;nbsp; &lt;/P&gt;&lt;P&gt; if intck('day',(INTNX('week',dt,0,'B' )),today())&amp;gt;= 7 then flag = 'This week' ;&lt;/P&gt;&lt;P&gt;else flag = 'last week' ;&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 tabulate data = date_flg;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class school sex flag;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; table school*sex,flag='No of student Registered'*n='';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="output.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/8297_output.PNG" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 13:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142359#M28541</guid>
      <dc:creator>Thamaraikannan</dc:creator>
      <dc:date>2014-12-09T13:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142360#M28542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="857609" data-username="Thamaraikannan" href="https://communities.sas.com/people/Thamaraikannan" id="jive-85760933553167031973186" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba;"&gt;Thamaraikannan&lt;/A&gt;&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much. Can I know how to add more columns type in the table? Can I modify the code like the following? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc tabulate data = date_flg;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; class school sex flag;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; table school*sex,flag='No of student Registered'*n='', flag = 'No of Student Registered 2'*n=", &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;flag = 'No of Student Registered 3'*n="&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 01:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142360#M28542</guid>
      <dc:creator>AmberForever</dc:creator>
      <dc:date>2014-12-10T01:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142361#M28543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-objectid="857609" data-objecttype="3" href="https://communities.sas.com/people/Thamaraikannan" style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #0e66ba;"&gt;Thamaraikannan&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Hi Tamara,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I know how to modify your code to have the the following table? Thank you so much! I have tried modify your codes...but not work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="source tbale.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8326_source tbale.png" width="450" /&gt; &lt;/P&gt;&lt;P&gt;&lt;IMG alt="output file.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8327_output file.png" style="font-size: 10pt; line-height: 1.5em;" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 07:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142361#M28543</guid>
      <dc:creator>AmberForever</dc:creator>
      <dc:date>2014-12-10T07:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142362#M28544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data src_rec;&lt;/P&gt;&lt;P&gt;input name $ sex $ school $ dt date9. score;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;AAA F Law 9-sep-14 10&lt;/P&gt;&lt;P&gt;BBB F IT 10-Aug-14 20&lt;/P&gt;&lt;P&gt;CCC M Law 19-Sep-14 30&lt;/P&gt;&lt;P&gt;DDD F Art 10-Dec-14 25&lt;/P&gt;&lt;P&gt;EEE F Law 9-sep-14 40&lt;/P&gt;&lt;P&gt;FFF M Biz 10-Aug-14 45&lt;/P&gt;&lt;P&gt;GGG F Law 9-Dec-14 55&lt;/P&gt;&lt;P&gt;HHH M IT&amp;nbsp; 6-Dec-14 50&lt;/P&gt;&lt;P&gt;III M Law 19-Nov-14 45&lt;/P&gt;&lt;P&gt;JJJ M Art 10-Aug-14 20&lt;/P&gt;&lt;P&gt;kkk F Law 9-Dec-14 25&lt;/P&gt;&lt;P&gt;lll F Biz 8-Dec-14 20&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 date_flg ;&lt;/P&gt;&lt;P&gt;set src_rec; &lt;/P&gt;&lt;P&gt;if intck('day',(INTNX('week',dt,0,'B' )),today())&amp;gt;= 7 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flag = 'This week' ;&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;flag = 'last week' ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc tabulate data = date_flg;&lt;/P&gt;&lt;P&gt; class school sex flag;&lt;/P&gt;&lt;P&gt; var score;&lt;/P&gt;&lt;P&gt; table (school*sex ),flag='No of student Registered'*n=''(flag='Sum of score'*score=''*sum='')(flag='Avg of score'*score=''*mean='') ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="output.PNG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/8328_output.PNG" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 09:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142362#M28544</guid>
      <dc:creator>Thamaraikannan</dc:creator>
      <dc:date>2014-12-10T09:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use sas code to make a table like this... (urgent！）</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142363#M28545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The sample data you're using illustrates why you shouldn't code "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt; line-height: 1.5em; background-color: #ffffff;"&gt;else do; &lt;/SPAN&gt;flag = 'last week' ; end;" but should calculate "last week" and then eventually have an other case like "else flag='earlier weeks'&amp;nbsp; "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below a code sample based on your code but using a format instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fmt_source;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format start date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length label $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain fmtname 'WeekGroup';&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain type 'N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do start=intnx('year',today(),-1) to today();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week=intck('week',start,today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select(week);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(0)&amp;nbsp;&amp;nbsp; label='This Week';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(1)&amp;nbsp;&amp;nbsp; label='Last Week';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise label=catx(' ',week,'weeks ago');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=fmt_source;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data src_rec;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input name $ sex $ school $ dt date9. score;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;AAA F Law 9-sep-14 10&lt;/P&gt;&lt;P&gt;BBB F IT 10-Aug-14 20&lt;/P&gt;&lt;P&gt;CCC M Law 19-Sep-14 30&lt;/P&gt;&lt;P&gt;DDD F Art 10-Dec-14 25&lt;/P&gt;&lt;P&gt;EEE F Law 9-sep-14 40&lt;/P&gt;&lt;P&gt;FFF M Biz 10-Aug-14 45&lt;/P&gt;&lt;P&gt;GGG F Law 9-Dec-14 55&lt;/P&gt;&lt;P&gt;HHH M IT&amp;nbsp; 6-Dec-14 50&lt;/P&gt;&lt;P&gt;III M Law 19-Nov-14 45&lt;/P&gt;&lt;P&gt;JJJ M Art 10-Aug-14 20&lt;/P&gt;&lt;P&gt;kkk F Law 9-Dec-14 25&lt;/P&gt;&lt;P&gt;lll F Biz 8-Dec-14 20&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;proc tabulate data = src_rec order=unformatted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; class school sex dt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var score;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format dt WeekGroup.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; table (school*sex ),dt='No of student Registered'*n=''(dt='Sum of score'*score=''*sum='')(dt='Avg of score'*score=''*mean='');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 11:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-sas-code-to-make-a-table-like-this-urgent/m-p/142363#M28545</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-12-10T11:43:14Z</dc:date>
    </item>
  </channel>
</rss>

