<?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 How to convert values on diagonal to long format? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923673#M363636</link>
    <description>&lt;P&gt;I have a data format like below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id    time1 time2  time3   
1       1                      
              2                
                    3          
2       1                      
              2                
                    3         &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The time was on diagonal for each people, but I want to convert it to a long format with one time variable and different times under it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID  Time
1     1
1     2
1     3
2     1
2     2
3     3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does anyone know how to do it? Thank you!&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>Tue, 09 Apr 2024 20:09:32 GMT</pubDate>
    <dc:creator>SAS-questioner</dc:creator>
    <dc:date>2024-04-09T20:09:32Z</dc:date>
    <item>
      <title>How to convert values on diagonal to long format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923673#M363636</link>
      <description>&lt;P&gt;I have a data format like below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id    time1 time2  time3   
1       1                      
              2                
                    3          
2       1                      
              2                
                    3         &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The time was on diagonal for each people, but I want to convert it to a long format with one time variable and different times under it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID  Time
1     1
1     2
1     3
2     1
2     2
3     3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does anyone know how to do it? Thank you!&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>Tue, 09 Apr 2024 20:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923673#M363636</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2024-04-09T20:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert values on diagonal to long format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923675#M363637</link>
      <description>&lt;P&gt;I would try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   time = max(time1,time2,time3);
   drop time1-time3;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2024 20:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923675#M363637</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-09T20:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert values on diagonal to long format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923691#M363641</link>
      <description>&lt;P&gt;Do your second and third rows &lt;EM&gt;&lt;STRONG&gt;really&lt;/STRONG&gt;&lt;/EM&gt; have blank ID values?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 01:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923691#M363641</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-04-10T01:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert values on diagonal to long format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923692#M363642</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id    time1 time2  time3  ;
cards; 
1       1       .       .        
.        .      2      .          
.        .      .      3          
2       1        .     .         
.        .      2       .         
.        .       .     3 
;
data want;
 set have(rename=(id=_id));
 retain id .;
 if not missing(_id) then id=_id;
 time=coalesce(of time1-time3);
 keep id time;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Apr 2024 02:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-values-on-diagonal-to-long-format/m-p/923692#M363642</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-04-10T02:07:09Z</dc:date>
    </item>
  </channel>
</rss>

