<?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: Values in fields-number of months passed since month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750210#M235918</link>
    <description>&lt;P&gt;Can you please provide the data in a SAS data step (instead of an Excel file)?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jun 2021 14:14:31 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-24T14:14:31Z</dc:date>
    <item>
      <title>Values in fields-number of months passed since month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750201#M235912</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the following task:&lt;/P&gt;
&lt;P&gt;For each customer ID there are multiple columns with information on varaible X and varaible W&amp;nbsp; during the months Jan 2021 till Jun 2021&lt;/P&gt;
&lt;P&gt;( The names of the columns X are in format XYYMM ,for example:X2101 is varaible X in Jan 2021)&lt;/P&gt;
&lt;P&gt;( The names of the columns W are in format XYYMM,for example:W2104 is varaible X in April 2021).&lt;/P&gt;
&lt;P&gt;There is also another column called month (numeric ) with values structure YYMM&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(for example: 2103 is March 2021).&lt;/P&gt;
&lt;P&gt;There are 3 versions for the soure data set (Have1 ,Have2,Have3).&lt;/P&gt;
&lt;P&gt;Task1 is to convert values to null in columns that lower than month value.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;For Customer ID=1&amp;nbsp; ,month=2102&amp;nbsp; so X2101 and X2102 and W2101 and W2102 should be converted to null values.&lt;/P&gt;
&lt;P&gt;Task2 is to create new varaibles: X1,X2,X3,X4,X5,X6,W1,W2,W3,W4,W5,W6&amp;nbsp; with information by number of months that passes since the month value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May anyone show a code that create "Wanted1" and "wanted2" data sets?&lt;/P&gt;
&lt;P&gt;What source data set is the best structure to work with? Have1 or Have2 or Have3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The task is to follow up the customer since he recieved a drug and it is important for us to look on the values by the times passes since he recieved the treatment ...&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 13:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750201#M235912</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-24T13:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Values in fields-number of months passed since month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750210#M235918</link>
      <description>&lt;P&gt;Can you please provide the data in a SAS data step (instead of an Excel file)?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 14:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750210#M235918</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-24T14:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Values in fields-number of months passed since month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750273#M235953</link>
      <description />
      <pubDate>Thu, 24 Jun 2021 18:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750273#M235953</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-24T18:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Values in fields-number of months passed since month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750274#M235954</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/***I am sending two ways to represet  source data set so you can work on each of them in order to get the desired wanted data set***/ 													
													
Data  Have1;													
Input ID month $  X2101 X2102 X2103 X2104 X2105 X2106 W2101 W2102 W2103 W2104 W2105 W2106													
cards;													
1	2102	10	8	42	43	19	32	9	7	38	39	17	29
2	2104	14	4	32	54	26	42	13	4	29	49	23	38
3	2101	25	5	13	65	73	43	23	5	12	59	66	39
4	2102	62	77	76	34	32	2	56	69	68	31	29	2
5	2103	42	34	54	54	65	34	38	31	49	49	59	31
6	2104	34	54	34	65	65	98	31	49	31	59	59	88
;													
Run;													
													
													
Data  Have2;													
Input ID mon $ X    W month $;													
cards;													
1	2101	10	9	2102									
1	2102	8	7	2102									
1	2103	42	38	2102									
1	2104	43	39	2102									
1	2105	19	17	2102									
1	2106	32	29	2102									
2	2101	14	13	2104									
2	2102	4	4	2104									
2	2103	32	29	2104									
2	2104	54	49	2104									
2	2105	26	23	2104									
2	2106	42	38	2104									
3	2101	25	23	2101									
3	2102	5	5	2101									
3	2103	13	12	2101									
3	2104	65	59	2101									
3	2105	73	66	2101									
3	2106	43	39	2101									
4	2101	62	56	2102									
4	2102	77	69	2102									
4	2103	76	68	2102									
4	2104	34	31	2102									
4	2105	32	29	2102									
4	2106	2	2	2102									
5	2101	42	38	2103									
5	2102	34	31	2103									
5	2103	54	49	2103									
5	2104	54	49	2103									
5	2105	65	59	2103									
5	2106	34	31	2103									
6	2101	34	31	2104									
6	2102	54	49	2104									
6	2103	34	31	2104									
6	2104	65	59	2104									
6	2105	65	59	2104									
6	2106	98	88	2104									
;													
Run;													
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 18:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750274#M235954</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-24T18:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Values in fields-number of months passed since month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750279#M235958</link>
      <description>&lt;P&gt;I know we have discussed this before. &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 19&lt;/A&gt;, Long beats Wide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to transpose the data set to a long data set, then leave it as long; and then most of what you describe will be easy, and furthermore, the subsequent analysis will also be easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have time to write code for you right now. Why don't you see if you can use PROC TRANSPOSE to obtain a long data set and then make missing values as needed.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 19:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Values-in-fields-number-of-months-passed-since-month/m-p/750279#M235958</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-24T19:04:45Z</dc:date>
    </item>
  </channel>
</rss>

