<?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 Need to fetch a single value from the existing dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39028#M7906</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Can you please elabrate the question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;S Ravuri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Mar 2012 10:23:36 GMT</pubDate>
    <dc:creator>sambasiva_ravuri_tcs_com</dc:creator>
    <dc:date>2012-03-21T10:23:36Z</dc:date>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39027#M7905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My datset is as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;obs&amp;nbsp;&amp;nbsp; f1&amp;nbsp; f2&amp;nbsp; f3&amp;nbsp; &lt;STRONG&gt;f4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp; 6 &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with respect to condition like if obs =3 and f4=8 i need to fetch the value &lt;STRONG&gt;8.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;how can i achieve this?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 09:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39027#M7905</guid>
      <dc:creator>shru</dc:creator>
      <dc:date>2012-03-21T09:31:44Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39028#M7906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Can you please elabrate the question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;S Ravuri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 10:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39028#M7906</guid>
      <dc:creator>sambasiva_ravuri_tcs_com</dc:creator>
      <dc:date>2012-03-21T10:23:36Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39029#M7907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to fetch one value from the dataset with respect to column name obs and f4.&lt;/P&gt;&lt;P&gt;So that when i run the code i only get the value &lt;STRONG&gt;8 as i mentioned.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; Thanks&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 10:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39029#M7907</guid>
      <dc:creator>shru</dc:creator>
      <dc:date>2012-03-21T10:58:16Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39030#M7908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data x;
 input obs&amp;nbsp;&amp;nbsp; f1&amp;nbsp; f2&amp;nbsp; f3&amp;nbsp; f4 ;
cards;
1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp; 4
2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp; 6
3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp; 8
;
run;
data want(keep=f4);
 i=3;
 set x point=i; 
 output;
 stop;
run;


&lt;/PRE&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;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 11:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39030#M7908</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-21T11:00:13Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39031#M7909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data want;&lt;/P&gt;&lt;P&gt;set x(firstobs=3 obs=3 keep=f4);&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;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 11:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39031#M7909</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-21T11:07:17Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39032#M7910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ksharp, Hai.Kuo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both worked well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;S Ravuri. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 11:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39032#M7910</guid>
      <dc:creator>sambasiva_ravuri_tcs_com</dc:creator>
      <dc:date>2012-03-21T11:18:34Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39033#M7911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hai.kuo and Ksharp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It worked fine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankss&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 11:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39033#M7911</guid>
      <dc:creator>shru</dc:creator>
      <dc:date>2012-03-21T11:52:17Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39034#M7912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is not as efficient as mine.&lt;/P&gt;&lt;P&gt;My code used Directly Access Method. However yours is Sequential Access Method.&lt;/P&gt;&lt;P&gt;If the dataset were very large. My code is better. &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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2012 08:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39034#M7912</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-22T08:23:09Z</dc:date>
    </item>
    <item>
      <title>Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39035#M7913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course! :smileysilly:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2012 11:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39035#M7913</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-22T11:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39036#M7914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am totally new in SAS programming. I need to calculate last 6 months of current month. and it should be in yyyymm format. (eg: 201308) I was able to get the current date. but cannot find a solution to update the table with last 6 months.&lt;/P&gt;&lt;P&gt;this is how I appraoched. Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;Data Month;&lt;/P&gt;
&lt;P&gt;Cur_month=date();&lt;/P&gt;
&lt;P&gt;Format Cur_month YYMMN.&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;/*may be something like this is what I need*/&lt;/P&gt;
&lt;P&gt;/*Mon1 = Cur_month-1;*/&lt;/P&gt;
&lt;P&gt;/*Mon2 = Cur_month-2;*/&lt;/P&gt;
&lt;P&gt;/*Mon3=Cur_month-3;*/&lt;/P&gt;
&lt;P&gt;/*I did not get the right value in these fields. I got something like&amp;nbsp; 19582, 19582, 19580*/&lt;/P&gt;
 &lt;/PRE&gt;&lt;P&gt;I tried to format it after calculating which again gave the value 201308. but it should be 201307, 201306, 201305&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 15:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39036#M7914</guid>
      <dc:creator>Eleenrose</dc:creator>
      <dc:date>2013-08-13T15:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39037#M7915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eleenrose;&lt;/P&gt;&lt;P&gt;It would have been better to create a new thread as your question has no apparent bearing on the this thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function you are looking for to create shifts of a data is INTNX.&lt;/P&gt;&lt;P&gt;I think you want Mon1 = INTNX("month",Cur_month, -1) ; The is an alignment parametere that can follow the -1 but you don't say whether the Mon1 should have a date represeting the begining, end, middle of the month or align with the same day of the month as Cur_month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your problem stems from subracting one day from the date value. If you used an MMDDYY format you would have seen your MonX variables decreasing by one day.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 17:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39037#M7915</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-08-13T17:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39038#M7916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we are into code optimization, then you may want to review the position of the keep statement so that you don't "waste" memory allocation for a data vector of 5 variables when you only need one &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eleenrose, the issue is that all dates formats are held by sas as the number of days since 1960jan01. As such, when you substrat a day to your variable, even though its format is yymmn, it actually substracts 1 day from the date numeric value and then converts it back as a yymmn format so if a given date value was on the 16th of the month, you would need to substract 16 to eventually see the formatted substraction result change month after formating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Intnx is the primary sas function to allow you to go around this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mon1 = intnx('month', cur_month, -1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on your desired result, you may want to check the documentation for the 4rth parameter. By default from the above, the result will be the equivalent of the first day of the previous month and not the "same day" of the previous month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Aug 2013 17:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39038#M7916</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-13T17:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fetch a single value from the existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39039#M7917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;I got what I wanted to do. I used Intnx and got it working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;mon1 = intnx('month', date(), -1);&lt;/P&gt;&lt;P&gt;mon2 = intnx('month', date(), -1);&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;format mon1, mon2,mon3.. yymmn6. ;&lt;/P&gt;&lt;P&gt;put (_all_)(=);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everybody for the help. I am totally new to this field and trying to learn as far as I can..:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again..&lt;/P&gt;&lt;P&gt;Eleen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2013 09:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-fetch-a-single-value-from-the-existing-dataset/m-p/39039#M7917</guid>
      <dc:creator>Eleenrose</dc:creator>
      <dc:date>2013-08-15T09:00:20Z</dc:date>
    </item>
  </channel>
</rss>

