<?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: Date variable from an array? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835213#M330190</link>
    <description>&lt;P&gt;hi i am solving a similar question did u get an proper answer&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2022 16:07:07 GMT</pubDate>
    <dc:creator>pransh</dc:creator>
    <dc:date>2022-09-26T16:07:07Z</dc:date>
    <item>
      <title>Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727766#M226419</link>
      <description>I am trying to use an array to create a date variable that combines individual day and month numeric values into a date in the year 1990 and recode to missing days and months that are -1, -13, -32&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Libname D “directory”;&lt;BR /&gt;Data have;&lt;BR /&gt;Set D.have;&lt;BR /&gt;Format dob mmddyy8.;&lt;BR /&gt;Array datec {2} day_c month_c;&lt;BR /&gt;Do i = 1 to 2;&lt;BR /&gt;Datec{i} = mdy(day_c, month_c, 1990);&lt;BR /&gt;If day_c in (-1,-13) then day_c =.;&lt;BR /&gt;If month_c in (-1,-32) then month_c =.;&lt;BR /&gt;&lt;BR /&gt;End;</description>
      <pubDate>Fri, 19 Mar 2021 14:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727766#M226419</guid>
      <dc:creator>ayosas</dc:creator>
      <dc:date>2021-03-19T14:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727767#M226420</link>
      <description>&lt;P&gt;This does not really make any sense.&lt;/P&gt;
&lt;P&gt;Please show some example input and what output you want for that input.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 14:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727767#M226420</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-19T14:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727772#M226423</link>
      <description>This is technically possible, but a really strange use of arrays. &lt;BR /&gt;Since you will only reference these variables once you don't need an array at all. &lt;BR /&gt;&lt;BR /&gt;What makes you think you need a loop?&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Mar 2021 14:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727772#M226423</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-19T14:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727774#M226424</link>
      <description>Thanks, I am working on an assignment that requires me to use loops and arrays to create 3 date variables. So I was thinking that an array would be needed for each set of days and months</description>
      <pubDate>Fri, 19 Mar 2021 14:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727774#M226424</guid>
      <dc:creator>ayosas</dc:creator>
      <dc:date>2021-03-19T14:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727790#M226426</link>
      <description>&lt;P&gt;In that case show an example of that situation.&lt;/P&gt;
&lt;P&gt;Sounds like you say three sets of month,day, year variables.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID M1 D1 Y1 M2 D2 Y2 M3 D3 Y3 
1 1 1 1980 2 2 1990 3 3 2000&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And you want to generate three date variables.&lt;/P&gt;
&lt;P&gt;So you could create a separate array for each of the types of variables and then loop over an index into the array to apply the same logic to each of the arrays.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array m m1-m3;
  array d d1-d3;
  array y y1-y3 ;
  array date date1-date3;
  do index=1 to dim(m);
     date[index] = mdy(m[index],d[index],y[index]);
  end;
  format date1-date3 yymmdd10.;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs  ID  M1  D1   Y1   M2  D2   Y2   M3  D3   Y3        date1       date2       date3

 1    1   1   1  1980   2   2  1990   3   3  2000  1980-01-01  1990-02-02  2000-03-03
&lt;/PRE&gt;
&lt;P&gt;If the values of the month variable are things like -1 and -13 in your example then the resulting DATE variable will be missing since such values cannot be used to generate a valid date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your real situation is different than my example then show a similar level of detail for your real problem.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 15:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/727790#M226426</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-19T15:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835193#M330173</link>
      <description>&lt;P&gt;hey,&lt;/P&gt;&lt;P&gt;wht if the year is not a variable in the data set and its just mentioned in the question that all of the month and date variable have year of 1990, then how to appraoch&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 15:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835193#M330173</guid>
      <dc:creator>pransh</dc:creator>
      <dc:date>2022-09-26T15:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835195#M330175</link>
      <description>your help will be really appreciated</description>
      <pubDate>Mon, 26 Sep 2022 15:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835195#M330175</guid>
      <dc:creator>pransh</dc:creator>
      <dc:date>2022-09-26T15:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835211#M330189</link>
      <description>&lt;P&gt;If you have a NEW question then start a new topic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can easily hard code the year, just use the actual value instead of a variable name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = mdy(month,day,1980);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Sep 2022 16:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835211#M330189</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-26T16:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date variable from an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835213#M330190</link>
      <description>&lt;P&gt;hi i am solving a similar question did u get an proper answer&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 16:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-variable-from-an-array/m-p/835213#M330190</guid>
      <dc:creator>pransh</dc:creator>
      <dc:date>2022-09-26T16:07:07Z</dc:date>
    </item>
  </channel>
</rss>

