<?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: Report with categories of multiple varaibles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712210#M219524</link>
    <description>Sorry but I dont understand&lt;BR /&gt;I defined start as 01JAN2020 and end as 05DEC2020 and calculated the difference between end and start that his 5 days.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 18 Jan 2021 19:33:15 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-01-18T19:33:15Z</dc:date>
    <item>
      <title>Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712041#M219436</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create a report from data set&amp;nbsp; SASHELP.CARS.&lt;/P&gt;
&lt;P&gt;Task1-I want to add a new column&amp;nbsp; to the raw data (sashelp.cars) with random date between 01.01.2021 and 05.01.2021&lt;/P&gt;
&lt;P&gt;Task2- I want to create a summary report&amp;nbsp; with following statistics calculations:&lt;/P&gt;
&lt;P&gt;SUM of MSRP&lt;/P&gt;
&lt;P&gt;Number of rows(actually it is number of transactions)&lt;/P&gt;
&lt;P&gt;Number of distinct&amp;nbsp;Cylinders&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These calculations will be done for each category of following variables:&lt;/P&gt;
&lt;P&gt;Type&lt;/P&gt;
&lt;P&gt;Origin&lt;/P&gt;
&lt;P&gt;EngineSize&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The calculation will be done for each date .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in the report will have 17 columns:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;var name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;category name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;SUM of MSRP (for each date)&lt;BR /&gt;Number of rows&amp;nbsp; (for each date)&lt;BR /&gt;Number of distinct&amp;nbsp;Cylinders (for each date)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to create the desired task please?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1610960023529.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53594i966B895E3B241396/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1610960023529.png" alt="Ronein_0-1610960023529.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $ typeF 
'Sedan','Hybrid','SUV'='Type_a'
'Sports'='Type_b'
'Truck','Wagon'='Type_c'
;
run;

proc format;
value $ OriginF
'Asia','Europe'='Asia,Europe'
'USA'='USA'
;
run;

proc format ;
value EngineSizeF
0-1.3='(a) till 1.3'
1.3-1.6='(b) 1.3-1.6'
1.6-2.0'=(c) 1.6-2.0'
2.0-high='(d) 2.0+';
run;
&lt;/CODE&gt;&lt;/PRE&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 08:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712041#M219436</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-01-18T08:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712074#M219448</link>
      <description>Once you have your dataset, you could do it with proc report or proc tabulate.</description>
      <pubDate>Mon, 18 Jan 2021 11:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712074#M219448</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-01-18T11:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712105#M219461</link>
      <description>&lt;P&gt;I know that can be done with proc report but my question was to see a code that do it and also to see a code that add dates column to raw data with random allocation of dates between 01/01/2021 and 05/01/2021&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 13:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712105#M219461</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-01-18T13:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712107#M219462</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-generate-random-dates-in-sas-over-a-certain-period-time/td-p/361161" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-generate-random-dates-in-sas-over-a-certain-period-time/td-p/361161&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, here is some code for getting the random dates. Do you know how to use proc report or proc tabulate?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 13:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712107#M219462</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-01-18T13:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712110#M219464</link>
      <description>&lt;P&gt;Add dates at random between Jan 2021 and May 2021 (from your example, the dates are always the first of the month, and the year is always 2021, so the only random thing would be the month)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assign a new variable containing random integers 1 through 5 to each observation indicating the random month, then turn the random integer into a day/month/year.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 13:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712110#M219464</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-18T13:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712119#M219469</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I know that can be done with proc report but my question was to see a code that do it and also to see a code that add dates column to raw data with random allocation of dates between 01/01/2021 and 05/01/2021&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have 3 separate variables in the same column I don't think that Proc Report will be your friend.&lt;/P&gt;
&lt;P&gt;Tabulate would have the date as the first Column dimension as a class variable with the other 3 nested inside:&lt;/P&gt;
&lt;P&gt;table type origin enginesize,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datevar *(msrp*sum&amp;nbsp;&amp;nbsp; n &amp;lt;maybe you don't define what Nr_rows means&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;you also do not define what nr_distinct_cylinders is supposed to be&amp;gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However If you intending what I think you are intending for the distinct cylinders you may be out of luck as that sort of summary likely needs to be done prior to the Tabulate or Report procedure as there is no "distinct values" statistic in Proc Tabulate or Report .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you expecting Proc Report or Tabulated to do a random column selection???&lt;/P&gt;
&lt;P&gt;Adding values like dates belongs before any report procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 14:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712119#M219469</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-18T14:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712137#M219479</link>
      <description>Thank you!&lt;BR /&gt;A few questions please:&lt;BR /&gt;1- I see that rand() is not working and then I changed it&lt;BR /&gt;2-I want to check the dates in order to verify that I get dates between 01/01/2021 and 05.01.2021&lt;BR /&gt;I expect to see 5 dates only!!&lt;BR /&gt;Why do I get much more???&lt;BR /&gt;&lt;BR /&gt;%let start=01/01/2021;&lt;BR /&gt;%let end=05/01/2021;&lt;BR /&gt;Data _null_;&lt;BR /&gt;start_SAS_date=input("&amp;amp;start",ddmmyy10.);&lt;BR /&gt;end_SAS_date=input("&amp;amp;end",ddmmyy10.);&lt;BR /&gt;dif=end_SAS_date-start_SAS_date;&lt;BR /&gt;call symput('start',put(start_SAS_date,best.));&lt;BR /&gt;call symput('dif',put(dif,best.));&lt;BR /&gt;run;&lt;BR /&gt;%put &amp;amp;start;&lt;BR /&gt;%put &amp;amp;dif;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Data RawDataTbl;&lt;BR /&gt;set SASHELP.cars;&lt;BR /&gt;format date_new ddmmyy10.;&lt;BR /&gt;date_new=&amp;amp;start+rand('uniform')*&amp;amp;dif;&lt;BR /&gt;Run;&lt;BR /&gt;proc sort data=RawDataTbl(keep=date_new)nodup;&lt;BR /&gt;by date_new;&lt;BR /&gt;run;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;	create table check_dates  as&lt;BR /&gt;	select  distinct  date_new	   &lt;BR /&gt;	from  RawDataTbl&lt;BR /&gt;;&lt;BR /&gt;QUIT;</description>
      <pubDate>Mon, 18 Jan 2021 15:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712137#M219479</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-01-18T15:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712141#M219481</link>
      <description>&lt;P&gt;Hi: When you get the dates into the data, you still have a basic assumption problem.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1610984775842.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53606i8F51A4F0A359CD7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1610984775842.png" alt="Cynthia_sas_0-1610984775842.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You show 3 different variables and their values in the first 2 columns on the report. This is the type of thing that TABULATE will do very nicely. But PROC REPORT would NOT do this unless you restructure the data. So what you want to do, aside from the random dates, seems more of a TABULATE report. And I'm not sure how you would calculate number of distinct cylinders. It seems to me that number of distinct cylinders for TYPE will be different than number of distinct cylinders for ENGINESIZE and both of those will be different than number of distinct cylinders for ORIGIN. So that column doesn't seem to be something that you would be able to get in just one variable.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 15:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712141#M219481</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-01-18T15:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712210#M219524</link>
      <description>Sorry but I dont understand&lt;BR /&gt;I defined start as 01JAN2020 and end as 05DEC2020 and calculated the difference between end and start that his 5 days.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jan 2021 19:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712210#M219524</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-01-18T19:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Report with categories of multiple varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712212#M219526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you!&lt;BR /&gt;A few questions please:&lt;BR /&gt;1- I see that rand() is not working and then I changed it&lt;BR /&gt;2-I want to check the dates in order to verify that I get dates between 01/01/2021 and 05.01.2021&lt;BR /&gt;I expect to see 5 dates only!!&lt;BR /&gt;Why do I get much more???&lt;BR /&gt;&lt;BR /&gt;%let start=01/01/2021;&lt;BR /&gt;%let end=05/01/2021;&lt;BR /&gt;Data _null_;&lt;BR /&gt;start_SAS_date=input("&amp;amp;start",ddmmyy10.);&lt;BR /&gt;end_SAS_date=input("&amp;amp;end",ddmmyy10.);&lt;BR /&gt;dif=end_SAS_date-start_SAS_date;&lt;BR /&gt;call symput('start',put(start_SAS_date,best.));&lt;BR /&gt;call symput('dif',put(dif,best.));&lt;BR /&gt;run;&lt;BR /&gt;%put &amp;amp;start;&lt;BR /&gt;%put &amp;amp;dif;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Data RawDataTbl;&lt;BR /&gt;set SASHELP.cars;&lt;BR /&gt;format date_new ddmmyy10.;&lt;BR /&gt;date_new=&amp;amp;start+rand('uniform')*&amp;amp;dif;&lt;BR /&gt;Run;&lt;BR /&gt;proc sort data=RawDataTbl(keep=date_new)nodup;&lt;BR /&gt;by date_new;&lt;BR /&gt;run;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;create table check_dates as&lt;BR /&gt;select distinct date_new &lt;BR /&gt;from RawDataTbl&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As I said, you just need to generate random months. The year you want is always 2021 and the day of the month is always 1, these are not random.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if you have generated random month numbers 1 through 5, then you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_new = mdy(random_month,1,2021);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 19:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Report-with-categories-of-multiple-varaibles/m-p/712212#M219526</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-18T19:38:21Z</dc:date>
    </item>
  </channel>
</rss>

