<?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 generate a (constant) variable that is the median of another variable ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96249#M20292</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you soooo much ! Code looks nice.. I'll try it see if it works &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeoffrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Apr 2013 14:09:37 GMT</pubDate>
    <dc:creator>JMMK007</dc:creator>
    <dc:date>2013-04-03T14:09:37Z</dc:date>
    <item>
      <title>How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96241#M20284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a (hopefully) very basic problem, but as I'm not an experienced user, i request some help. I have to create a dummy variable, say y, that is 1 is the observation on an underlying variable x is above the median of x and 0 otherwise. I can't genrerate the median as a variable: when i use the median(x) function in a data step to create a new variable, it actually just duplicates the variable x... Can anybody help me ?&lt;/P&gt;&lt;P&gt;Thank you so much in advance,&lt;/P&gt;&lt;P&gt;Jeoffrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 12:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96241#M20284</guid>
      <dc:creator>JMMK007</dc:creator>
      <dc:date>2013-04-03T12:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96242#M20285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't really understand what you want to do.&lt;/P&gt;&lt;P&gt;Can you describe it using sample input and output data? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 12:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96242#M20285</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-04-03T12:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96243#M20286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the reply ! Well my data are on my other computer (that is not connected on the internet, but the program goes approximately like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data project.cis;&lt;/P&gt;&lt;P&gt;set project.cis;&lt;/P&gt;&lt;P&gt;med_x=median(x);&lt;/P&gt;&lt;P&gt;if x &amp;gt;= med_x then z=1;&lt;/P&gt;&lt;P&gt;else if x&amp;lt;med_x then z=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My hope would have been that z = 1&amp;nbsp; for values of x above the median and 0 otherwise. But the variable med_x in the example above is not constant and takes the same values as x ??? I'm a little lost...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 13:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96243#M20286</guid>
      <dc:creator>JMMK007</dc:creator>
      <dc:date>2013-04-03T13:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96244#M20287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still not getting what your want.&lt;/P&gt;&lt;P&gt;But the median function used in the data step, will pick the median value from a list of values/variables.&lt;/P&gt;&lt;P&gt;In your case, when your list just contain one variable, well, the median on 1 is...1.&lt;/P&gt;&lt;P&gt;My guess is that you probably want to calculate the median of x between rows, then you have to use different techniques. If you need some guidance, again, provide some sample data and desired output.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 13:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96244#M20287</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-04-03T13:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96245#M20288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed that's exactly what i want: compute a median across rows (not columns!) and compare the value in each row to that overall median &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose the following data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data example;&lt;BR /&gt;input id exp;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 10&lt;/P&gt;&lt;P&gt;2 20&lt;/P&gt;&lt;P&gt;3 30&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The median of 'exp' is obviously 20. What i'd like to get is a new variable that takes value for observation 1 (below the median) and 1 for observations 2 and 3 (at the median and above)... Is this possible ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeoffrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 13:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96245#M20288</guid>
      <dc:creator>JMMK007</dc:creator>
      <dc:date>2013-04-03T13:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96246#M20289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still confused, do you want to put 10 in a variable named bellow, and 20 and 30 into a variable "median_above", sort of?&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exp&amp;nbsp;&amp;nbsp; bellow above&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&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; 20&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&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; 30&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 13:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96246#M20289</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-04-03T13:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96247#M20290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh thank you for your kind reply !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort of, but not exactly: i just want to create a single binary variable that takes value 1 for observations above the median (i.e. ID = 2 and 3) and 0 for values below that median (i.e. ID = 1).. Well if i could already generate the output you've just shown, i thionk i could find my way &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeoffrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96247#M20290</guid>
      <dc:creator>JMMK007</dc:creator>
      <dc:date>2013-04-03T14:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96248#M20291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is what you are after, make sure your RAM is large enough to hold your array():&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;input id exp;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 10&lt;/P&gt;&lt;P&gt;2 20&lt;/P&gt;&lt;P&gt;3 30&lt;/P&gt;&lt;P&gt;4 32&lt;/P&gt;&lt;P&gt;5 21&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;call symputx('nobs',nobs);&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set example nobs=nobs;&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 want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set example;&lt;/P&gt;&lt;P&gt;array med(&amp;amp;nobs) _temporary_;&lt;/P&gt;&lt;P&gt;med(_i)=exp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _m=median(of med(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set example;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ind=ifn(exp&amp;lt;_m,0,1);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*drop _:;*/&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;_m is the calculated median.&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96248#M20291</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-04-03T14:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96249#M20292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you soooo much ! Code looks nice.. I'll try it see if it works &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeoffrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96249#M20292</guid>
      <dc:creator>JMMK007</dc:creator>
      <dc:date>2013-04-03T14:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96250#M20293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For calculating medians, you are probably best off using PROC SUMMARY.&lt;/P&gt;&lt;P&gt;The you need to join/merge the result back to your original data, and then do your binary assignment in that step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96250#M20293</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-04-03T14:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96251#M20294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="119192" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; said: For calculating medians, you are probably best off using PROC SUMMARY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"best off" is a very bold statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I got from a test:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;378 data test;&lt;/P&gt;&lt;P&gt;379 do i=1 to 30000000;&lt;/P&gt;&lt;P&gt;380 output;&lt;/P&gt;&lt;P&gt;381 end;&lt;/P&gt;&lt;P&gt;382 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEST has 30000000 observations and 1 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 1.19 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 1.21 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;383&lt;/P&gt;&lt;P&gt;384 proc summary data=test print median;&lt;/P&gt;&lt;P&gt;385 var i;&lt;/P&gt;&lt;P&gt;386 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WARNING: A shortage of memory has caused the quantile computations to terminate prematurely for&lt;/P&gt;&lt;P&gt;&amp;nbsp; QMETHOD=OS. Consider using QMETHOD=P2.&lt;/P&gt;&lt;P&gt;NOTE: The affected statistics will be missing from the corresponding classification levels.&lt;/P&gt;&lt;P&gt;NOTE: There were 30000000 observations read from the data set WORK.TEST.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SUMMARY used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 9.48 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 13.58 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;387&lt;/P&gt;&lt;P&gt;388&lt;/P&gt;&lt;P&gt;389 data _null_;&lt;/P&gt;&lt;P&gt;390 call symputx('nobs',nobs);&lt;/P&gt;&lt;P&gt;391 stop;&lt;/P&gt;&lt;P&gt;392 set test nobs=nobs;&lt;/P&gt;&lt;P&gt;393 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;394&lt;/P&gt;&lt;P&gt;395 data _null_;&lt;/P&gt;&lt;P&gt;396 do _n_=1 to &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;397 set test;&lt;/P&gt;&lt;P&gt;398 array med(&amp;amp;nobs) _temporary_;&lt;/P&gt;&lt;P&gt;399 med(_n_)=i;&lt;/P&gt;&lt;P&gt;400 end;&lt;/P&gt;&lt;P&gt;401 Median=median(of med(*));&lt;/P&gt;&lt;P&gt;402 put Median=;&lt;/P&gt;&lt;P&gt;403 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Median=15000000.5&lt;/P&gt;&lt;P&gt;NOTE: There were 30000000 observations read from the data set WORK.TEST.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 4.65 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 4.55 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Summary ended up failed, regardless of double amount of time consumed.&amp;nbsp; If we roll back the total number of obs to the extend that Proc Summary can run:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;404 data test;&lt;/P&gt;&lt;P&gt;405 do i=1 to 20000000;&lt;/P&gt;&lt;P&gt;406 output;&lt;/P&gt;&lt;P&gt;407 end;&lt;/P&gt;&lt;P&gt;408 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEST has 20000000 observations and 1 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 0.76 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 0.71 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;409&lt;/P&gt;&lt;P&gt;410 proc summary data=test print median;&lt;/P&gt;&lt;P&gt;411 var i;&lt;/P&gt;&lt;P&gt;412 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: There were 20000000 observations read from the data set WORK.TEST.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SUMMARY used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 6.56 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 9.51 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;413&lt;/P&gt;&lt;P&gt;414&lt;/P&gt;&lt;P&gt;415 data _null_;&lt;/P&gt;&lt;P&gt;416 call symputx('nobs',nobs);&lt;/P&gt;&lt;P&gt;417 stop;&lt;/P&gt;&lt;P&gt;418 set test nobs=nobs;&lt;/P&gt;&lt;P&gt;419 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;420&lt;/P&gt;&lt;P&gt;421 data _null_;&lt;/P&gt;&lt;P&gt;422 do _n_=1 to &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;423 set test;&lt;/P&gt;&lt;P&gt;424 array med(&amp;amp;nobs) _temporary_;&lt;/P&gt;&lt;P&gt;425 med(_n_)=i;&lt;/P&gt;&lt;P&gt;426 end;&lt;/P&gt;&lt;P&gt;427 Median=median(of med(*));&lt;/P&gt;&lt;P&gt;428 put Median=;&lt;/P&gt;&lt;P&gt;429 run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Median=10000000.5&lt;/P&gt;&lt;P&gt;NOTE: There were 20000000 observations read from the data set WORK.TEST.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp; real time 2.96 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp; cpu time 2.97 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is less than half of what Array can do in term of performance. Test has been done on Win7, 64bit, with 4G RAM, Intel G850, and SAS 9.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96251#M20294</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-04-03T14:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96252#M20295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with LinusH, you're better off using proc summary or means in this case and merging in the results. It's also simpler for beginners &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;input id exp;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 10&lt;/P&gt;&lt;P&gt;2 20&lt;/P&gt;&lt;P&gt;3 30&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*calculate the median;&lt;/P&gt;&lt;P&gt;proc means data=example noprint;&lt;/P&gt;&lt;P&gt;output out=median_value median(exp)=exp_median;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data example2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set example;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *add in the median value;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then set median_value;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if exp&amp;lt;exp_median then flag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else flag=0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 15:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96252#M20295</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-04-03T15:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96253#M20296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC STDIZE has fast percentile algorithm that you may find interesting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 15:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96253#M20296</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-04-03T15:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a (constant) variable that is the median of another variable ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96254#M20297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thnk you so much, it works perfectly &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; !!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Apr 2013 12:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-a-constant-variable-that-is-the-median-of/m-p/96254#M20297</guid>
      <dc:creator>JMMK007</dc:creator>
      <dc:date>2013-04-05T12:45:59Z</dc:date>
    </item>
  </channel>
</rss>

