<?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: problem transposing I think in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235306#M43086</link>
    <description>&lt;P&gt;&lt;BR /&gt;Thanks. Gotta get my SQL up to date.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Nov 2015 17:03:13 GMT</pubDate>
    <dc:creator>cj9000</dc:creator>
    <dc:date>2015-11-18T17:03:13Z</dc:date>
    <item>
      <title>problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235270#M43072</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I am trying to create a temp&amp;nbsp;SAS data set containing the avg price for each stock &lt;BR /&gt;and number of values used to create the avg. In addition the data set should contain &lt;BR /&gt;the minimum and maximum price for each stock. A listing of the data should look like below.&lt;BR /&gt;The code I have used is below the listing.&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;Charles&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="5" width="623"&gt;
&lt;P&gt;Listing of Summary&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="125"&gt;
&lt;P&gt;Symbol&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;Price_Mean&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;Price_N&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;Price_Min&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;Price_Max&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="125"&gt;
&lt;P&gt;AVID&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;41.2500&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;41.25&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;41.25&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="125"&gt;
&lt;P&gt;BAC&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;51.0400&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;49.90&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;52.10&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="125"&gt;
&lt;P&gt;CSCO&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;20.3125&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;19.75&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;21.00&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="125"&gt;
&lt;P&gt;IBM&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;77.8000&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;75.00&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;81.00&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="125"&gt;
&lt;P&gt;LU&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;2.5400&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;2.53&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="125"&gt;
&lt;P&gt;2.55&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data stockprices;
   infile datalines;
   length Symbol $ 4;
   input Symbol $ @;
   do Date = '01jan2007'd  to '05jan2007'd;
      input Price @;
      if not missing(Price) then output;
   end;
   format Date mmddyy10.;
datalines;
CSCO 19.75 20 20.5 21 .
IBM 76 78 75 79 81
LU 2.55 2.53 . . .
AVID 41.25 . . . .
BAC 51 51 51.2 49.9 52.1
;
/*
proc print data=stockprices;
run;*/

proc sort data=stockprices out=sorted;
   by symbol date;
run;
/*
proc print data=sorted;
run;*/

proc means data=sorted nway noprint;
   class Symbol;
   output out=symbols;
run;
/*
proc print data=symbols;
run;*/

proc transpose data=symbols prefix=stock
               out=oneper;
   by symbol;
   
run;
proc print data=oneper;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 15:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235270#M43072</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2015-11-18T15:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235277#M43076</link>
      <description>&lt;P&gt;For future posts, can you just use the normal area for posting text, and the code window for code. &amp;nbsp;Its difficult to read having to scroll across. &amp;nbsp;As for your point, you can get the output you want by a small change to the means code:&lt;/P&gt;
&lt;PRE&gt;proc means data=sorted nway noprint;
   class Symbol;
   output out=symbols n=price_n mean=price_mean ...;
run;&lt;/PRE&gt;
&lt;P&gt;If you put the elements on the output statement line, they will appear as variables rather than data rows (which is the default). &amp;nbsp;So statistic=variable name. &amp;nbsp;You wont need the transpose then.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 15:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235277#M43076</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-18T15:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235281#M43078</link>
      <description>&lt;P&gt;If the only purpose of the dataset is to print then skip all the manipulation an go directly to one of the report procedures such as Proc Report or Tabulate.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data= stockprices;
   class symbol;
   var price;
   table symbol, price*(mean*f=f6.2 n min*f=f6.2 max*f=f6.2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use Proc Summary instead of means, the default output is somewhat different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sorted nway ;
   class Symbol;
   var price;
   output out=symbols mean= n= min= max= /autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No need to sort before either Proc Means or Proc Summary to use the class option. The output will be sorted by the class variables within _type_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 15:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235281#M43078</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-11-18T15:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235282#M43079</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select symbol,Avg(price) as Price_Mean,count(*) as Price_N, Min(Price) as Price_Min,&lt;BR /&gt;max(price) as Price_Max&lt;BR /&gt;from stockprices&lt;BR /&gt;group by symbol;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 16:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235282#M43079</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-11-18T16:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235284#M43080</link>
      <description>&lt;P&gt;Here is another solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select distinct&lt;BR /&gt;symbol,&lt;BR /&gt;mean(price) as Price_Mean,&lt;BR /&gt;count(price) as Price_N,&lt;BR /&gt;min(price) as Price_Min,&lt;BR /&gt;max(price) as Price_Max&lt;BR /&gt;from stockprices&lt;BR /&gt;group by symbol;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 16:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235284#M43080</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-11-18T16:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235302#M43083</link>
      <description>&lt;P&gt;Thank you. It worked out great as well as some of the other solutins. wow&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 16:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235302#M43083</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2015-11-18T16:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235303#M43084</link>
      <description>&lt;P&gt;Thanks this works out as well. Not having to do all that coding was great.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 16:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235303#M43084</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2015-11-18T16:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235305#M43085</link>
      <description>Sorry about how I posted this. Haven't much experience with the community yet.</description>
      <pubDate>Wed, 18 Nov 2015 16:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235305#M43085</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2015-11-18T16:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235306#M43086</link>
      <description>&lt;P&gt;&lt;BR /&gt;Thanks. Gotta get my SQL up to date.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 17:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235306#M43086</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2015-11-18T17:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: problem transposing I think</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235308#M43087</link>
      <description>&lt;P&gt;Thanks, my sql isn't up to par yet but it will be.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 17:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-transposing-I-think/m-p/235308#M43087</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2015-11-18T17:04:31Z</dc:date>
    </item>
  </channel>
</rss>

