<?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: case statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213750#M267586</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the solution that I came up with, not sure that this will work but I wouldn't have store3 in store1 column, store1 in store2 column and store4 in store3 column:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;input postcode $ store $&amp;nbsp; sales rank;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;3000,storec,289809,1&lt;/P&gt;&lt;P&gt;3000,storeb,37979,2&lt;/P&gt;&lt;P&gt;3000,storee,17865,3&lt;/P&gt;&lt;P&gt;3000,Restof,9541,4&lt;/P&gt;&lt;P&gt;3162,store3,49700,1&lt;/P&gt;&lt;P&gt;3162,store1,28977,2&lt;/P&gt;&lt;P&gt;3162,store4,18783,3&lt;/P&gt;&lt;P&gt;3162,Restof,28846,4&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;proc sort data=have;by postcode store;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have(drop=rank) out=tran_have(drop=_name_);by postcode store;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=tran_have out=prep(drop=_name_);by postcode;id store;var col1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 May 2015 11:53:07 GMT</pubDate>
    <dc:creator>Steelers_In_DC</dc:creator>
    <dc:date>2015-05-13T11:53:07Z</dc:date>
    <item>
      <title>case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213748#M267584</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 have the below table :&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="242"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-color: currentcolor black black currentcolor;" width="50"&gt;&lt;DIV data-object-id="3720877" data-object-type="1"&gt;postcode&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; border-color: currentcolor;" width="79"&gt;store&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; border-color: currentcolor;" width="49"&gt;sales&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none; border-color: currentcolor;" width="64"&gt;rank&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;storec&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;289809&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;storeb&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;37979&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;storee&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;17865&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;Restof&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;9541&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3162&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;store3&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;49700&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3162&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;store1&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;28977&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3162&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;store4&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;18783&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none; border-color: currentcolor black black;"&gt;3162&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;Restof&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;28846&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;4&amp;nbsp; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And i am trying to get the output as below:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;I have used Case statement to get the &lt;SPAN style="font-size: 13.3333330154419px;"&gt;below &lt;/SPAN&gt;output however no luck, i have more than 1000 postcodes in this data-set, so any ideas would be great..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 569px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="84"&gt;&lt;DIV data-object-id="3720877" data-object-type="1"&gt;postcode&lt;/DIV&gt;&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="47"&gt;Store1&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="46"&gt;store2&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="46"&gt;store3&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="87"&gt;store1 spend&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="87"&gt;store2 spend&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="87"&gt;store3 spend&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="85"&gt;rest ofspend&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;3000&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;storec&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;storeb&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;storee&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $289,809.00 &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 37,979.00 &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 17,865.00 &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 9,541.00 &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;3162&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;store3&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;store1&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none; border-color: currentcolor black black currentcolor;"&gt;store4&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 49,700.00 &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 28,977.00 &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 18,783.00 &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt; $ 28,846.00 &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 01:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213748#M267584</guid>
      <dc:creator>boin</dc:creator>
      <dc:date>2015-05-13T01:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213749#M267585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're trying to transpose your data from long to wide. Two common methods are via a data step or a proc transpose. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples of the following are here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm" title="http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm"&gt;SAS Learning Module: Reshaping wide to long using a data step&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/modules/wtol_transpose.htm" title="http://www.ats.ucla.edu/stat/sas/modules/wtol_transpose.htm"&gt;SAS Learning Module: How to reshape data wide to long using proc transpose&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd recommend the data step in this particular case, especially if you have exactly 4 of each. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you were trying to do this via sql I would do it via merging subqueries rather than CASE statements. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 01:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213749#M267585</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-05-13T01:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213750#M267586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the solution that I came up with, not sure that this will work but I wouldn't have store3 in store1 column, store1 in store2 column and store4 in store3 column:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;input postcode $ store $&amp;nbsp; sales rank;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;3000,storec,289809,1&lt;/P&gt;&lt;P&gt;3000,storeb,37979,2&lt;/P&gt;&lt;P&gt;3000,storee,17865,3&lt;/P&gt;&lt;P&gt;3000,Restof,9541,4&lt;/P&gt;&lt;P&gt;3162,store3,49700,1&lt;/P&gt;&lt;P&gt;3162,store1,28977,2&lt;/P&gt;&lt;P&gt;3162,store4,18783,3&lt;/P&gt;&lt;P&gt;3162,Restof,28846,4&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;proc sort data=have;by postcode store;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have(drop=rank) out=tran_have(drop=_name_);by postcode store;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=tran_have out=prep(drop=_name_);by postcode;id store;var col1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 11:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213750#M267586</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-05-13T11:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213751#M267587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The simplest way is using proc means . Otherwise consider speed , you could use MERGE skill.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf"&gt;http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;input postcode $ store $&amp;nbsp; sales rank;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;3000,storec,289809,1&lt;/P&gt;&lt;P&gt;3000,storeb,37979,2&lt;/P&gt;&lt;P&gt;3000,storee,17865,3&lt;/P&gt;&lt;P&gt;3000,Restof,9541,4&lt;/P&gt;&lt;P&gt;3162,store3,49700,1&lt;/P&gt;&lt;P&gt;3162,store1,28977,2&lt;/P&gt;&lt;P&gt;3162,store4,18783,3&lt;/P&gt;&lt;P&gt;3162,Restof,28846,4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; select max(n) into : n&lt;/P&gt;&lt;P&gt;&amp;nbsp; from (select count(*) as n from have group by postcode);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc summary data=have ;&lt;/P&gt;&lt;P&gt;by postcode;&lt;/P&gt;&lt;P&gt;output out=want idgroup(out[&amp;amp;n] (store&amp;nbsp; sales rank)=);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 12:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-statement/m-p/213751#M267587</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-13T12:39:15Z</dc:date>
    </item>
  </channel>
</rss>

