<?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: Imputation age variable wide dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501650#M554</link>
    <description>&lt;P&gt;So, I need have a table only with ID and AGEs variables. After this imputation process, I will merge the new table with the older one, dropping the old AGEs variables. My new table is like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input age1999 id age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;58 1 57 56 55 54 53 52 51 50 49&lt;/P&gt;&lt;P&gt;. 2 . . 39 38 . . 35 . .&lt;/P&gt;&lt;P&gt;. 3 23 22 21 20 19 18 17 16 15&lt;/P&gt;&lt;P&gt;. 4 66 65 64 63 62 61 60 59 58&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;28 5 27 26 25 24 . . . . .&lt;/P&gt;&lt;P&gt;. 6 . 39 . . . . . . .&lt;/P&gt;&lt;P&gt;. 7 . 22 80 . 68 47 72 38 .&lt;/P&gt;&lt;P&gt;79 8 . . . . . . . . 22&lt;/P&gt;&lt;P&gt;89 9 57 . . . . . . . .&lt;/P&gt;&lt;P&gt;30 10 . . . . . . . . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make special atention to the 7th, 8th and 9th observations. I have some inconsistencies in the declaration of age. Therefore, I intend to use the first age declared in time (the first year that age is declared) to correct the inconsistencies in the imputation process of age variable. What I want would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;input id&amp;nbsp;age1999 age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 58 57 56 55 54 53 52 51 50 49&lt;/P&gt;&lt;P&gt;2 42 41 40 39 38 37 36 35 34 33&lt;/P&gt;&lt;P&gt;3 24 23 22 21 20 19 18 17 16 15&lt;/P&gt;&lt;P&gt;4 67 66 65 64 63 62 61 60 59 58&lt;/P&gt;&lt;P&gt;5 28 27 26 25 24 23 22 21 20 19&lt;/P&gt;&lt;P&gt;6 41 40 39 38 37 36 35 34 33 32&lt;/P&gt;&lt;P&gt;7 46 45 44 43 42 41 40 39 38 37&lt;/P&gt;&lt;P&gt;8 31 30 29 28 27 26 25 24 23 22&lt;/P&gt;&lt;P&gt;9 58 57 56 55 54 53 52 51 50 49&lt;/P&gt;&lt;P&gt;10 30 29 28 27 26 25 24 23 22 21&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Oct 2018 18:46:54 GMT</pubDate>
    <dc:creator>MFraga</dc:creator>
    <dc:date>2018-10-04T18:46:54Z</dc:date>
    <item>
      <title>Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501582#M540</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to impute missing values for my "age"&amp;nbsp;variable. My data is organized as&amp;nbsp;one observation per line. So I have multiple variables for the year of collection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see at the 6th, 7th and 8th observations, I have some inconsistencies in the declared age. So, when age is missing, I would like to consider the first age declared as the good to fill all the other missing values for that observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is an example of the structure of my dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id&amp;nbsp;age1990 age1991 age1992 age1993 age1994 age1995 age1996 age1997 age1998 age1999;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 22 23 24 25 26 27 28 29 30 31&lt;/P&gt;&lt;P&gt;2 . . 35 . . 38 39 . . .&lt;/P&gt;&lt;P&gt;3 . 15 16 17 18 19 20 21 22 23&lt;/P&gt;&lt;P&gt;3 58 59 60 61 62 63 64 65 66 .&lt;/P&gt;&lt;P&gt;4 . . . . . 24 25 26 27 28&lt;/P&gt;&lt;P&gt;5 . . . . . . . 39 . .&lt;/P&gt;&lt;P&gt;6 . 38 72 47 68 . 80 22 . .&lt;/P&gt;&lt;P&gt;7 22 . . . . . . . . 79&lt;/P&gt;&lt;P&gt;8 . . . . . . . . 57 89&lt;/P&gt;&lt;P&gt;9 . . . . . . . . . 30;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is what I want as a result would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;input id&amp;nbsp;age1990 age1991 age1992 age1993 age1994 age1995 age1996 age1997 age1998 age1999;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 22 23 24 25 26 27 28 29 30 31&lt;/P&gt;&lt;P&gt;2 33 34 35 36 37 38 39 40 41 42&lt;/P&gt;&lt;P&gt;3 14 15 16 17 18 19 20 21 22 23&lt;/P&gt;&lt;P&gt;3 58 59 60 61 62 63 64 65 66 67&lt;/P&gt;&lt;P&gt;4 19 20 21 22 23 24 25 26 27 28&lt;/P&gt;&lt;P&gt;5 32 33 34 35 36 37 38 39 40 41&lt;/P&gt;&lt;P&gt;6 37 38 39 40 41 42 43 44 45 46&lt;/P&gt;&lt;P&gt;7 22 23 24 25 26 27 28 29 30 31&lt;/P&gt;&lt;P&gt;8 49 50 51 52 53 54 55 56 57 58&lt;/P&gt;&lt;P&gt;9 21 22 23 24 25 26 27 28 29 30;&lt;/P&gt;&lt;P&gt;run;&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;&lt;P&gt;I have tried this program using the DO function, but it does not work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array age (10) age1990-age1999;&lt;/P&gt;&lt;P&gt;do i = 1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if age(i) = . then age(i) = age(i+1) - 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a clue about how I could make this imputation ? Thank you!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501582#M540</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T16:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501602#M544</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

input id age1990 age1991 age1992 age1993 age1994 age1995 age1996 age1997 age1998 age1999;

datalines;
1 22 23 24 25 26 27 28 29 30 31
2 . . 35 . . 38 39 . . .
3 . 15 16 17 18 19 20 21 22 23
3 58 59 60 61 62 63 64 65 66 .
4 . . . . . 24 25 26 27 28
5 . . . . . . . 39 . .
6 . 38 72 47 68 . 80 22 . .
7 22 . . . . . . . . 79
8 . . . . . . . . 57 89
9 . . . . . . . . . 30
;

run;
data want;
set have;
array t age:;
array j age:;
k=coalesce(of t(*));
k1=whichn(k,of t(*));
k2=t(k1)- (k1-1);
do over j;
j=k2;
k2+1;
end;
drop k:;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501602#M544</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T17:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501626#M548</link>
      <description>&lt;P&gt;Hi, novinosrin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help, but it does not work. SAS sends a error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: array subscript out of rang at line 521 colonne 6. I have more than 300000 observations in my dataset. Do you have any other clue why it does not work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501626#M548</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T17:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501628#M549</link>
      <description>&lt;P&gt;Is your sample a good representative of you real?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;300000&amp;nbsp; is nothing in my opinion.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am wondering if you correctly implemented the code&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501628#M549</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T17:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501630#M550</link>
      <description>&lt;P&gt;Yes, it is. The only difference I face is the variable age arrangement. When I ckeck the table, it does not follow the exact order like that :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id age1990 age1991 age1992 ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, it is like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;age1999 id age1998 age1997 age1996 age1995 age1994...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and my dataset has many other variables in between id and ages variables.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501630#M550</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T17:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501632#M551</link>
      <description>&lt;P&gt;Well, do any of those vars have prefix age besides the variables we need?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That could kill the array&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Plus if your variable age arrangement is not in order, the sequence logic will anyway defeat the purpose unless we sort the array with call sortn and modify the logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That;s the problem as it leads me to guess as I do not know your data&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 18:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501632#M551</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T18:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501634#M552</link>
      <description>&lt;P&gt;Yes,&amp;nbsp; do have other variables with the age prefix. But I created a new table only with the id and age1990-1999 variables and I tried to run your conding, but it does not work neither...&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 18:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501634#M552</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T18:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501636#M553</link>
      <description>&lt;P&gt;Please simulate the new table you created&amp;nbsp; with some fake data and post it here. Let me try from my end&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 18:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501636#M553</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T18:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501650#M554</link>
      <description>&lt;P&gt;So, I need have a table only with ID and AGEs variables. After this imputation process, I will merge the new table with the older one, dropping the old AGEs variables. My new table is like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input age1999 id age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;58 1 57 56 55 54 53 52 51 50 49&lt;/P&gt;&lt;P&gt;. 2 . . 39 38 . . 35 . .&lt;/P&gt;&lt;P&gt;. 3 23 22 21 20 19 18 17 16 15&lt;/P&gt;&lt;P&gt;. 4 66 65 64 63 62 61 60 59 58&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;28 5 27 26 25 24 . . . . .&lt;/P&gt;&lt;P&gt;. 6 . 39 . . . . . . .&lt;/P&gt;&lt;P&gt;. 7 . 22 80 . 68 47 72 38 .&lt;/P&gt;&lt;P&gt;79 8 . . . . . . . . 22&lt;/P&gt;&lt;P&gt;89 9 57 . . . . . . . .&lt;/P&gt;&lt;P&gt;30 10 . . . . . . . . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make special atention to the 7th, 8th and 9th observations. I have some inconsistencies in the declaration of age. Therefore, I intend to use the first age declared in time (the first year that age is declared) to correct the inconsistencies in the imputation process of age variable. What I want would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;input id&amp;nbsp;age1999 age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 58 57 56 55 54 53 52 51 50 49&lt;/P&gt;&lt;P&gt;2 42 41 40 39 38 37 36 35 34 33&lt;/P&gt;&lt;P&gt;3 24 23 22 21 20 19 18 17 16 15&lt;/P&gt;&lt;P&gt;4 67 66 65 64 63 62 61 60 59 58&lt;/P&gt;&lt;P&gt;5 28 27 26 25 24 23 22 21 20 19&lt;/P&gt;&lt;P&gt;6 41 40 39 38 37 36 35 34 33 32&lt;/P&gt;&lt;P&gt;7 46 45 44 43 42 41 40 39 38 37&lt;/P&gt;&lt;P&gt;8 31 30 29 28 27 26 25 24 23 22&lt;/P&gt;&lt;P&gt;9 58 57 56 55 54 53 52 51 50 49&lt;/P&gt;&lt;P&gt;10 30 29 28 27 26 25 24 23 22 21&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 18:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501650#M554</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T18:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501660#M555</link>
      <description>&lt;P&gt;Thank you, Can you confirm this order plz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input &lt;STRONG&gt;age1999 id age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks just a reverse sequence, so biggie but I would like you to confirm to avoid going back and forth.&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, 04 Oct 2018 18:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501660#M555</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T18:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501664#M556</link>
      <description>&lt;P&gt;Yes, I confirm. My variables are organized in a reverse sequence.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501664#M556</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T19:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501666#M557</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236673"&gt;@MFraga&lt;/a&gt;&amp;nbsp;I trust our communication skills aren't bad &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here you go:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input age1999 id age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990;
datalines;
58 1 57 56 55 54 53 52 51 50 49
. 2 . . 39 38 . . 35 . .
. 3 23 22 21 20 19 18 17 16 15
. 4 66 65 64 63 62 61 60 59 58
28 5 27 26 25 24 . . . . .
. 6 . 39 . . . . . . .
. 7 . 22 80 . 68 47 72 38 .
79 8 . . . . . . . . 22
89 9 57 . . . . . . . .
30 10 . . . . . . . . .
;
run;

data want;
set have;
array rev[*] age1990-age1999;
array t age:;
array j age:;
call sortn(of t(*));
k=coalesce(of t(*));
k1=whichn(k,of t(*));
k2=t(k1)- (k1-1);
do over j;
j=k2;
k2+1;
end;
call sortn(of rev[*]);
drop k:;
run;
 
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I still have to modify the logic, let me try and come back&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501666#M557</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T19:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501671#M558</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236673"&gt;@MFraga&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First off, my sincere apologies for the previous thread. I request you to kindly ignore. I overlooked the requirement and I beg your pardon. Turns out it is really easy.&lt;/P&gt;
&lt;P&gt;I think I have nailed it this time. Test the below which works for your latest sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input age1999 id age1998 age1997 age1996 age1995 age1994 age1993 age1992 age1991 age1990;
datalines;
58 1 57 56 55 54 53 52 51 50 49
. 2 . . 39 38 . . 35 . .
. 3 23 22 21 20 19 18 17 16 15
. 4 66 65 64 63 62 61 60 59 58
28 5 27 26 25 24 . . . . .
. 6 . 39 . . . . . . .
. 7 . 22 80 . 68 47 72 38 .
79 8 . . . . . . . . 22
89 9 57 . . . . . . . .
30 10 . . . . . . . . .
;
run;

data want;
set have;
array rev[*] age1990-age1999;
array j age1990-age1999;
k=coalesce(of rev(*));
k1=whichn(k,of rev(*));
k2=rev(k1)- (k1-1);
do over j;
j=k2;
k2+1;
end;
drop k:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501671#M558</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T19:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501677#M559</link>
      <description>&lt;P&gt;It works! Thank you so much for your help,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501677#M559</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-04T19:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Imputation age variable wide dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501678#M560</link>
      <description>&lt;P&gt;Pleasure is all mine. Thank you for the nice question. Have fun and take care :)!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Imputation-age-variable-wide-dataset/m-p/501678#M560</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T19:48:04Z</dc:date>
    </item>
  </channel>
</rss>

