<?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: is it possible to &amp;quot;unflatten&amp;quot; files using SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330337#M74077</link>
    <description>&lt;P&gt;the macros worked beautifully!!! Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 06 Feb 2017 22:17:24 GMT</pubDate>
    <dc:creator>K_S</dc:creator>
    <dc:date>2017-02-06T22:17:24Z</dc:date>
    <item>
      <title>is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/329982#M73917</link>
      <description>&lt;P&gt;We can easily create flat files using proc transpose or by using arrays.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do is to "unflatten" a file that is currently flat.&lt;/P&gt;&lt;P&gt;Is it possible?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 22:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/329982#M73917</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-04T22:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/329985#M73918</link>
      <description>In most cases yes. But it depends on the nature of your data. &lt;BR /&gt;Please exemplify with sample have and want data sets.</description>
      <pubDate>Sat, 04 Feb 2017 22:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/329985#M73918</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-04T22:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330039#M73950</link>
      <description>&lt;P&gt;Also note that PROC TRANSPOSE can work in both directions: &amp;nbsp;wide to narrow, and narrow to wide.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2017 19:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330039#M73950</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-05T19:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330043#M73951</link>
      <description>&lt;P&gt;So what I have looks like this....&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;participant ID&lt;/TD&gt;&lt;TD&gt;contact 1&lt;/TD&gt;&lt;TD&gt;contact 2&lt;/TD&gt;&lt;TD&gt;type of relationship 1&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;type of&lt;/P&gt;&lt;P&gt;relationship 2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;gender of contact 1&lt;/TD&gt;&lt;TD&gt;gender of contact 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;KS&lt;/TD&gt;&lt;TD&gt;RS&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&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TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;JR&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;DD&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&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>Sun, 05 Feb 2017 20:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330043#M73951</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-05T20:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330044#M73952</link>
      <description>&lt;P&gt;yes, that is probably the way to go. I posted what I have and what I want to end up with in reply to another poster. Would be great if you could look at it and suggest a code to use.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2017 20:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330044#M73952</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-05T20:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330065#M73963</link>
      <description>&lt;P&gt;In that post, is the sample data your actual variables, or just representative of your actual variables? &amp;nbsp;If it's just representative, how is the actual data different? &amp;nbsp;There would be "many more" of something, but it's difficult to tell what.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2017 23:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330065#M73963</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-05T23:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330069#M73964</link>
      <description>&lt;P&gt;Nope, not my actual variables or data (REB wouldn't be happy about that!).&lt;/P&gt;&lt;P&gt;My actual dataset looks just like the example I provided, but it is 'wider'.&lt;/P&gt;&lt;P&gt;I have ~ 250 participants and then I have 10 contacts per participant and all kinds of data about the relationship between the participants and each one of their 10 contacts. Does this help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 00:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330069#M73964</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-06T00:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330172#M74003</link>
      <description>&lt;P&gt;Having only two contacts in a row can be held by next code.&lt;/P&gt;
&lt;P&gt;If the are more contacts in a row you can use either arrays or a macro like demostrated:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input part_ID   
      contact_1  $     contact_2 $
      type_of_rel_1    type_of_rel_2
      gender_1   $     gender_2  $ ;
datalines;
1   KS  RS  1   1   M   F
2   LB  GM  2   1   F   F
3   JR  DD  2   2   M   M
; run;

data want(keep=part_id contact type_of_rel gender);
 set have;
     contact = contact_1;
     type_of_rel = type_of_rel_1;
     gender = gender_1;
     output;
     
     contact = contact_2;
     type_of_rel = type_of_rel_2;
     gender = gender_2;
     output;         
run;     &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; %macro out(n);    
    contact = contact_&amp;amp;n;
     type_of_rel = type_of_rel_&amp;amp;n;
     gender = gender_&amp;amp;n;
     output;   
%mend out;&lt;BR /&gt;
 &lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;data want(keep=part_id contact type_of_rel gender);
 set have;&lt;BR /&gt;     %out(1);&lt;BR /&gt;     %out(2);&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You can even do last step &amp;nbsp;dynamical:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doit(loop);
data want(keep=part_id contact type_of_rel gender);
 set have;
      %do i=1 %to &amp;amp;loop;
         %out(&amp;amp;i);
      %end;
run;
%mend doit;
%doit(2);   /* 2 for two contact per row */
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Feb 2017 13:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330172#M74003</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-06T13:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330179#M74005</link>
      <description>&lt;P&gt;You have several good suggestions so far.&amp;nbsp; I would lean toward a DATA step as well, but using arrays:&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;array con {10} contact1-contact10;&lt;/P&gt;
&lt;P&gt;array typ {10} type_of_relationship1- type_of_relationship10;&lt;/P&gt;
&lt;P&gt;array gen {10} gender1-gender10;&lt;/P&gt;
&lt;P&gt;do _n_=1 to 10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; contact = con{_n_};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; type_of_relationship = typ{_n_};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; gender = gen{_n_};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep id contact type_of_relationship gender;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need more array statements, one for each set of variables in your data.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 13:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330179#M74005</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-06T13:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330331#M74071</link>
      <description>&lt;P&gt;hmmm...it didn't work...&lt;/P&gt;&lt;P&gt;It did flip the dataset, but all the values were missing...&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 22:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330331#M74071</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-06T22:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330337#M74077</link>
      <description>&lt;P&gt;the macros worked beautifully!!! Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 22:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330337#M74077</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-06T22:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330339#M74079</link>
      <description>&lt;P&gt;That's strange, since the technique is very straightforward.&amp;nbsp; Can you share the log?&amp;nbsp; It may be a simple thing like changing the spelling of existing variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(If possible, it wouldn't hurt to share the contents of a single observation from your incoming data.)&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 22:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330339#M74079</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-06T22:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330346#M74084</link>
      <description>&lt;P&gt;there were no error messages in the log.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much for the code though. You gave me enough breadcrumbs to find my way, I think.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll spend some time thinking about it and if I still can't figure it out, I'll let you know &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 22:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330346#M74084</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-02-06T22:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: is it possible to "unflatten" files using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330373#M74098</link>
      <description>&lt;P&gt;pay attention - contact and gender are character type.&lt;/P&gt;
&lt;P&gt;using array need add $ sign:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array con {10} &lt;STRONG&gt;$&lt;/STRONG&gt; &amp;nbsp;contact1-contact10;&lt;/P&gt;
&lt;P&gt;array typ {10} type_of_relationship1- type_of_relationship10;&lt;/P&gt;
&lt;P&gt;array gen {10} &lt;STRONG&gt;$&lt;/STRONG&gt; &amp;nbsp;gender1-gender10;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 02:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-it-possible-to-quot-unflatten-quot-files-using-SAS/m-p/330373#M74098</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-07T02:45:52Z</dc:date>
    </item>
  </channel>
</rss>

