<?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: SAS ARRAY - DATE FORMATS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363438#M86069</link>
    <description>&lt;P&gt;The next part of your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FLAG + 1;
IF FLAG &amp;lt;= 3 THEN DO; RESORT{FLAG} = RESORT_ID;		END;
IF FLAG &amp;lt;= 3 THEN DO; INTERV{FLAG} = INTERVAL;		END;
IF FLAG &amp;lt;= 3 THEN DO; STARTDT{FLAG} = START_DT;		END;
IF FLAG &amp;lt;= 3 THEN DO; ENTERDT{FLAG} = ENTER_DT;		END;
IF FLAG &amp;lt;= 3 THEN DO; REGION{FLAG} = PRIM_REGION;	END;
IF FLAG &amp;lt;= 3 THEN DO; CHANNEL{FLAG} = ENTRY_OPR_ID;	END;
END;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can be replaced into:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FLAG + 1;
IF FLAG &amp;lt;= 3 THEN DO; 
    RESORT{FLAG} = RESORT_ID;
    INTERV{FLAG} = INTERVAL;
    STARTDT{FLAG} = START_DT;	
    ENTERDT{FLAG} = ENTER_DT;	
    REGION{FLAG} = PRIM_REGION;
    CHANNEL{FLAG} = ENTRY_OPR_ID;
END;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;having same result with less coding and easier to read.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2017 14:01:46 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-06-01T14:01:46Z</dc:date>
    <item>
      <title>SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363421#M86063</link>
      <description>&lt;P&gt;&amp;nbsp;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below code whereby some of my variables that I specify to be dates don't show in my output field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I format STARTDT and ENTERDT to be date9. fields in my output?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA DEPOSITS_ARRAY_BASE;
ARRAY RESORT 		{3} $500.;
ARRAY INTERV 		{3} $500.;
ARRAY STARTDT 		{3} DATE9.;
ARRAY ENTERDT		{3} DATE9.;
ARRAY REGION		{3} $500.;
ARRAY CHANNEL		{3} $500.;

FLAG=0;
DO UNTIL (LAST.SBR_ID);
SET DEPOSITS;
BY SBR_ID;
FLAG + 1;
IF FLAG &amp;lt;= 3 THEN DO; RESORT{FLAG} = RESORT_ID;		END;
IF FLAG &amp;lt;= 3 THEN DO; INTERV{FLAG} = INTERVAL;		END;
IF FLAG &amp;lt;= 3 THEN DO; STARTDT{FLAG} = START_DT;		END;
IF FLAG &amp;lt;= 3 THEN DO; ENTERDT{FLAG} = ENTER_DT;		END;
IF FLAG &amp;lt;= 3 THEN DO; REGION{FLAG} = PRIM_REGION;	END;
IF FLAG &amp;lt;= 3 THEN DO; CHANNEL{FLAG} = ENTRY_OPR_ID;	END;
END;
DROP 	FLAG ROW SPB_TYPE SPB_STAT XCH_SPB_REL_NO &lt;BR /&gt;        RESORT_ID INTERVAL START_DT ENTER_DT PRIM_REGION ENTRY_OPR_ID;
RUN;&lt;/PRE&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>Thu, 01 Jun 2017 13:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363421#M86063</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-06-01T13:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363427#M86064</link>
      <description>&lt;P&gt;You can only assign lengths, not formats in an array definition. Use a separate format statement like in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
x1 = today();
output;
x1 = today() + 1;
output;
x1 = today() +2 ;
output;
run;

data want;
array dates{3} 4;
format dates1-dates3 date9.;
do i = 1 to 3;
  set have;
  dates{i} = x1;
end;
drop i x1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 13:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363427#M86064</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-01T13:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363434#M86066</link>
      <description>&lt;P&gt;Can I use an array to format numeric values already created?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if I wanted an array to format 3 columns, StartDT1 - StartDT3 to be DATE9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 13:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363434#M86066</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-06-01T13:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363435#M86067</link>
      <description>&lt;P&gt;You need to use the format statement to assign formats.&lt;/P&gt;
&lt;P&gt;In your case:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format StartDT1-StartDT3 date9.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 13:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363435#M86067</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-01T13:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363437#M86068</link>
      <description>Sorry, I don't have a clue when it comes to arrays - your response doesn't make any sense to me, I need to see the whole code to understand</description>
      <pubDate>Thu, 01 Jun 2017 14:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363437#M86068</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-06-01T14:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363438#M86069</link>
      <description>&lt;P&gt;The next part of your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FLAG + 1;
IF FLAG &amp;lt;= 3 THEN DO; RESORT{FLAG} = RESORT_ID;		END;
IF FLAG &amp;lt;= 3 THEN DO; INTERV{FLAG} = INTERVAL;		END;
IF FLAG &amp;lt;= 3 THEN DO; STARTDT{FLAG} = START_DT;		END;
IF FLAG &amp;lt;= 3 THEN DO; ENTERDT{FLAG} = ENTER_DT;		END;
IF FLAG &amp;lt;= 3 THEN DO; REGION{FLAG} = PRIM_REGION;	END;
IF FLAG &amp;lt;= 3 THEN DO; CHANNEL{FLAG} = ENTRY_OPR_ID;	END;
END;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can be replaced into:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FLAG + 1;
IF FLAG &amp;lt;= 3 THEN DO; 
    RESORT{FLAG} = RESORT_ID;
    INTERV{FLAG} = INTERVAL;
    STARTDT{FLAG} = START_DT;	
    ENTERDT{FLAG} = ENTER_DT;	
    REGION{FLAG} = PRIM_REGION;
    CHANNEL{FLAG} = ENTRY_OPR_ID;
END;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;having same result with less coding and easier to read.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 14:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363438#M86069</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-06-01T14:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363441#M86071</link>
      <description>&lt;P&gt;When you assign an array to already existing variables, you must supply the list of variables in the array statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array mydates{*} startdate enddate somedate;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use the same list in a format statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format startdate enddate somedate date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you create an arrray and do not supply names for the individual variables, two things can happen&lt;/P&gt;
&lt;P&gt;- existing variables that fit the array name(+index) scheme are represented by the array:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date1 = today();
date2 = date1 + 1;
date3 = date2 + 1;
run;

data want;
set have;
array date{3};
do i = 1 to 3;
  date{i} = date{i} + 1;
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that dataset want will contain the same variables as dataset have.&lt;/P&gt;
&lt;P&gt;- if no fitting variables exist, they will be created:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date1 = today();
date2 = date1 + 1;
date3 = date2 + 1;
run;

data want;
set have;
array dates{3};
do i = 1 to 3;
  dates{i} = date1;
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that dataset want now contains six variables.&lt;/P&gt;
&lt;P&gt;So, when you create array dates{*} without naming any variables, you will find that it will contain variable dates1, dates2, dates3 and so on; you can use the list form in a format statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let maxdates=9;

data want;
array dates{&amp;amp;maxdates};
format dates1-dates&amp;amp;maxdates date9.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 14:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363441#M86071</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-01T14:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363444#M86073</link>
      <description>&lt;P&gt;Next part of your code is wrong:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ARRAY RESORT 		{3} $500.;
ARRAY INTERV 		{3} $500.;
ARRAY STARTDT 		{3} DATE9.;
ARRAY ENTERDT		{3} DATE9.;
ARRAY REGION		{3} $500.;
ARRAY CHANNEL		{3} $500.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ARRAY&amp;nbsp;statement is a tool to assign a name to a list of variables, of same type,&lt;/P&gt;
&lt;P&gt;in order to enable relate to an array member (a speceific variable) by index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ARRAY is not the tool to assign formats to variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;array varx {3} var1 var2 var3; &amp;nbsp;/* can be shorten to var1-var3 */&lt;/P&gt;
&lt;P&gt;in this example VARX is the name of the array combined of 3 variables.&lt;/P&gt;
&lt;P&gt;You relate to the second variable in the array, either by VAR2 or by VARX(2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to assing formats to those variables use the FORMAT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; format var1-var3 comma6.2; &amp;nbsp; /* or any other format */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 14:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363444#M86073</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-06-01T14:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS ARRAY - DATE FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363454#M86077</link>
      <description>&lt;P&gt;A format is a tool for telling SAS how to display the values of the variable. &amp;nbsp;It is NOT how you define a variable. A SAS variable is either a fixed length character string or a floating point number. &amp;nbsp;In an ARRAY statement you can optionally define the type and length of the variables, but there is no way to attach a format to the variables using the ARRAY statement. &amp;nbsp;To attach a format you need use a FORMAT or ATTRIB statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that when specifing a variable's length you do not need to include a period. &amp;nbsp;Periods are used when specifying a format so that the parser can distinquish them from variable names or other keywords. &amp;nbsp;SAS will silently ignore the extra periods that you had included after the lengths in your ARRAY statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select max(nobs) into :max_obs trimmed
  from (select sbr_id,count(*) as nobs from deposits group by 1)
  ;
quit;

data deposits_array_base;
  array resort (&amp;amp;max_obs) $500;
  array interv (&amp;amp;max_obs) $500;
  array startdt (&amp;amp;max_obs) 8;
  array enterdt (&amp;amp;max_obs) 8;
  array region (&amp;amp;max_obs) $500;
  array channel (&amp;amp;max_obs) $500;
  format startdt: enterdt: date9. ;
  do flag=1 to &amp;amp;max_obs until (last.sbr_id);
    set deposits;
    by sbr_id;
    resort(flag) = resort_id;
    interv(flag) = interval;
    startdt(flag) = start_dt;
    enterdt(flag) = enter_dt;
    region(flag) = prim_region;
    channel(flag) = entry_opr_id;
  end;
  drop flag row spb_type spb_stat xch_spb_rel_no resort_id interval
       start_dt enter_dt prim_region entry_opr_id
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 15:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-ARRAY-DATE-FORMATS/m-p/363454#M86077</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-01T15:14:42Z</dc:date>
    </item>
  </channel>
</rss>

