<?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: Need Urgent Help again!! Appreciate it. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261748#M50988</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33792"&gt;@Loko﻿&lt;/a&gt; has a nice solution, i would just do some cosmetics and expansion:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=ex noprint nway;
class Region;
var GDP;
output
  out=want1 (drop=_:)
  min(GDP)=min_GDP max(GDP)=max_GDP
  idgroup (min(GDP) out (City) = LeastCity)
  idgroup (max(GDP)  out (City)=BestCity)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Apr 2016 14:37:02 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-04-06T14:37:02Z</dc:date>
    <item>
      <title>Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261725#M50976</link>
      <description>&lt;P&gt;How can I get the city of smallest GDP and largest GDP &amp;nbsp;in each region&amp;nbsp;of following example data set;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ex;&lt;BR /&gt;input City $ Region $ GDP;&lt;BR /&gt;cards;&lt;/P&gt;&lt;P&gt;City1&amp;nbsp;E 11.1&lt;BR /&gt;&lt;SPAN&gt;City2&lt;/SPAN&gt;&amp;nbsp;E 12.5&lt;BR /&gt;&lt;SPAN&gt;City3&lt;/SPAN&gt;&amp;nbsp;E 5.5&lt;BR /&gt;&lt;SPAN&gt;City4&lt;/SPAN&gt;&amp;nbsp;A 8.5&lt;BR /&gt;&lt;SPAN&gt;City5&amp;nbsp;&lt;/SPAN&gt;A 9.5&lt;BR /&gt;&lt;SPAN&gt;City6&amp;nbsp;&lt;/SPAN&gt;A 10.5&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;I would like to have result table with city, region, smallest and&amp;nbsp;largest. Thanks a lot again. I appreciate it.&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>Wed, 06 Apr 2016 14:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261725#M50976</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261729#M50977</link>
      <description>&lt;P&gt;(whoops, didn't see that you wanted the city. I'll work on that)&lt;/P&gt;
&lt;P&gt;Try&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; select region, min(gdp) as mininum, max(gdp) as maximum&lt;BR /&gt; from ex&lt;BR /&gt; group by region;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261729#M50977</guid>
      <dc:creator>mbuchecker</dc:creator>
      <dc:date>2016-04-06T14:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261734#M50979</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=ex;
by region gdp;
run;

data want;
set ex;
by region;
retain city_small gdp_small;
keep region city_small gdp_small city_large gdp_large;
if first.region
then do;
  city_small = city;
  gdp_small = gdp;
end;
if last.region
then do;
  city_large = city;
  gdp_large = gdp;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261734#M50979</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-06T14:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261738#M50982</link>
      <description>&lt;P&gt;Proc Summary / Proc means would do the trick too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Summary data=ex nway;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class city region;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var gdp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=work.results(DROP=_:) max(gdp)=maximum min(gdp)=minimum;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261738#M50982</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2016-04-06T14:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261739#M50983</link>
      <description>&lt;P&gt;alright, not pretty but:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=ex out=sort;&lt;BR /&gt; by Region descending gdp;&lt;BR /&gt;data max;&lt;BR /&gt; set sort;&lt;BR /&gt; by region descending gdp;&lt;BR /&gt; type='Maximum';&lt;BR /&gt; if first.region;&lt;BR /&gt;run;&lt;BR /&gt; proc sort data=ex out=sort;&lt;BR /&gt; by Region gdp;&lt;BR /&gt;data min;&lt;BR /&gt; set sort;&lt;BR /&gt; by region gdp;&lt;BR /&gt; type='Minimum';&lt;BR /&gt; if first.region;&lt;BR /&gt;run;&lt;BR /&gt;data combine;&lt;BR /&gt;set max min;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261739#M50983</guid>
      <dc:creator>mbuchecker</dc:creator>
      <dc:date>2016-04-06T14:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261741#M50984</link>
      <description>&lt;P&gt;proc means data=ex noprint nway;&lt;BR /&gt;class Region;&lt;BR /&gt;var GDP;&lt;BR /&gt;output out=want min(GDP)=min_GDP max(GDP)=max_GDP&lt;BR /&gt;idgroup (max(GDP)&amp;nbsp; out (City)=BestCity);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261741#M50984</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-04-06T14:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261747#M50987</link>
      <description>&lt;P&gt;It shows like that in the log :"The variable city_large in the DROP, KEEP, or RENAME list has never been referenced.."&lt;/P&gt;&lt;P&gt;Very close the table I want. but in the table it shows only smallest county and smallest number.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261747#M50987</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261748#M50988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33792"&gt;@Loko﻿&lt;/a&gt; has a nice solution, i would just do some cosmetics and expansion:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=ex noprint nway;
class Region;
var GDP;
output
  out=want1 (drop=_:)
  min(GDP)=min_GDP max(GDP)=max_GDP
  idgroup (min(GDP) out (City) = LeastCity)
  idgroup (max(GDP)  out (City)=BestCity)
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261748#M50988</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-06T14:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261749#M50989</link>
      <description>&lt;P&gt;Sorry...I got it...I was wrong in typing. Thanks you so much. I greatly appreciated it.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261749#M50989</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261751#M50990</link>
      <description>&lt;P&gt;The way I interpret this, you would need two CITY values (one for the smallest GDP, one for the largest).&amp;nbsp; Here's an approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by region gdp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by region;&lt;/P&gt;
&lt;P&gt;if first.region then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; type='Smallest';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if last.region then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; type='Largest';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261751#M50990</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-06T14:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261752#M50991</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80016"&gt;@Cathy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;It shows like that in the log :"The variable city_large in the DROP, KEEP, or RENAME list has never been referenced.."&lt;/P&gt;
&lt;P&gt;Very close the table I want. but in the table it shows only smallest county and smallest number.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hmm&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ex;
input City $ Region $ GDP;
cards;
City1 E 11.1
City2 E 12.5
City3 E 5.5
City4 A 8.5
City5 A 9.5
City6 A 10.5
;
run;

proc sort data=ex;
by region gdp;
run;

data want;
set ex;
by region;
retain city_small gdp_small;
keep region city_small gdp_small city_large gdp_large;
if first.region
then do;
  city_small = city;
  gdp_small = gdp;
end;
if last.region
then do;
  city_large = city;
  gdp_large = gdp;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;show this log for the second datastep:&lt;/P&gt;
&lt;PRE&gt;32         data want;
33         set ex;
34         by region;
35         retain city_small gdp_small;
36         keep region city_small gdp_small city_large gdp_large;
37         if first.region
38         then do;
39           city_small = city;
40           gdp_small = gdp;
41         end;
42         if last.region
43         then do;
44           city_large = city;
45           gdp_large = gdp;
46           output;
47         end;
48         run;

NOTE: There were 6 observations read from the data set WORK.EX.
NOTE: The data set WORK.WANT has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;
&lt;P&gt;and PROC PRINT gives me this:&lt;/P&gt;
&lt;PRE&gt;                                                          city_     gdp_    city_     gdp_
                                         Obs    Region    small    small    large    large

                                          1       A       City4     8.5     City6     10.5
                                          2       E       City3     5.5     City2     12.5
&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261752#M50991</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-06T14:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261756#M50994</link>
      <description>I greatly appreciate your help. Yes...I got it. again.Thank you so much.</description>
      <pubDate>Wed, 06 Apr 2016 14:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261756#M50994</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261757#M50995</link>
      <description>Thanks a lot. This work too. I appreciate your time and help.</description>
      <pubDate>Wed, 06 Apr 2016 14:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261757#M50995</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261759#M50997</link>
      <description>&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261759#M50997</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261760#M50998</link>
      <description>Thanks a lot for your help and time. I appreciate it.</description>
      <pubDate>Wed, 06 Apr 2016 14:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261760#M50998</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261761#M50999</link>
      <description>Thanks a lot for your help and time again. I greatly appreciate it.</description>
      <pubDate>Wed, 06 Apr 2016 14:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261761#M50999</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261765#M51001</link>
      <description>&lt;P&gt;Thanks a lot for your time and help. It works too. I greatly appreciate it.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261765#M51001</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T14:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need Urgent Help again!! Appreciate it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261804#M51010</link>
      <description>If I want to get two largest gdp by city and two smallest gdp by city in one data set, how can I do that? Please help me again. Thanks.</description>
      <pubDate>Wed, 06 Apr 2016 16:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Urgent-Help-again-Appreciate-it/m-p/261804#M51010</guid>
      <dc:creator>Cathy</dc:creator>
      <dc:date>2016-04-06T16:06:23Z</dc:date>
    </item>
  </channel>
</rss>

