<?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: Array for character variable with two changing components in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752503#M237054</link>
    <description>&lt;PRE&gt;datalines;
1801 1
1802 1
1803 0
1804 0
1805 1
.
.
.
1851 0
1901 1
1902 0&lt;/PRE&gt;&lt;P&gt;Each variable is a dummy variable taking on the value of 0 or 1. It is looking like the above, but it would be orded horizontally in the SAS dataset as every week is a variable on its own.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;/P&gt;&lt;P&gt;Frederik&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jul 2021 09:17:55 GMT</pubDate>
    <dc:creator>Taasby</dc:creator>
    <dc:date>2021-07-07T09:17:55Z</dc:date>
    <item>
      <title>Array for character variable with two changing components</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752501#M237052</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing data on a weekly basis. Each week has its own (character) variable - e.g. week 32 of 2010 is labelled y1032. What I want to do is to keep only data from 2018, 2019, and 2020 (keeping all weeks within a given year) - i.e keppeing 52*3 = 156 weeks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- 1801, 1802, ... 1852.&lt;/P&gt;&lt;P&gt;- 1901, 1902, ... 1952&lt;/P&gt;&lt;P&gt;- 2001, 2002, ... 2052&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think an array should do the job. However, I'm having a hard time setting up a proper array as there is a "0" before the first 9 weeks within every year. Any suggestions on how to go over this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Frederik&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 08:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752501#M237052</guid>
      <dc:creator>Taasby</dc:creator>
      <dc:date>2021-07-07T08:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Array for character variable with two changing components</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752502#M237053</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;what does your data structure look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is this what you're looking for?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input week $;
   datalines;
1801
1802
1852
1901
1902
1952
2001
2002
2052
1701
1702
1752
2101
2102
2152
;
run;

data want;
   set have;
   if '18'&amp;lt;=:week&amp;lt;=:'20';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 09:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752502#M237053</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-07-07T09:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Array for character variable with two changing components</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752503#M237054</link>
      <description>&lt;PRE&gt;datalines;
1801 1
1802 1
1803 0
1804 0
1805 1
.
.
.
1851 0
1901 1
1902 0&lt;/PRE&gt;&lt;P&gt;Each variable is a dummy variable taking on the value of 0 or 1. It is looking like the above, but it would be orded horizontally in the SAS dataset as every week is a variable on its own.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;/P&gt;&lt;P&gt;Frederik&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 09:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752503#M237054</guid>
      <dc:creator>Taasby</dc:creator>
      <dc:date>2021-07-07T09:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Array for character variable with two changing components</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752505#M237056</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/351376"&gt;@Taasby&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;.... as every week is a variable on its own.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;which is always a VERY BAD IDEA. Do not keep data in structure, see Maxim 19.&lt;/P&gt;
&lt;P&gt;As you can see, with a long dataset layout the code practically writes itself.&lt;/P&gt;
&lt;P&gt;If you receive data in a wide layout, always transpose to long immediately upon import.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 09:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752505#M237056</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-07T09:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Array for character variable with two changing components</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752518#M237065</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/351376"&gt;@Taasby&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/351376"&gt;@Taasby&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Each week has its own (character) variable - e.g. week 32 of 2010 is labelled y1032. What I want to do is to keep only data from 2018, 2019, and 2020 (keeping all weeks within a given year) - i.e keppeing 52*3 = 156 weeks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have(keep=y18: y19: y20:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have(keep=y1801-y1852 y1901-y1952 y2001-y2052);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the second case, make sure that you don't miss a week 53. Add more variables to the KEEP= lists if needed.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 10:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752518#M237065</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-07T10:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Array for character variable with two changing components</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752522#M237068</link>
      <description>&lt;P&gt;It did the job! Cheers! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 11:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-for-character-variable-with-two-changing-components/m-p/752522#M237068</guid>
      <dc:creator>Taasby</dc:creator>
      <dc:date>2021-07-07T11:27:00Z</dc:date>
    </item>
  </channel>
</rss>

