<?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 rearranging variables back to the original datasets in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46577#M12422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Those two data steps when posted as an example, since we do not know the structure of your actual datasets.&amp;nbsp; There is no need for you to type any variable names if you already have the two versions of the dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Mar 2012 15:41:41 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-03-28T15:41:41Z</dc:date>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46567#M12412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an output sas dataset that arrange variables by alphabetical orders. How do i arrange them back to the original order as in the raw data sets in the most efficient way?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 08:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46567#M12412</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-03-28T08:20:21Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46568#M12413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;options user=work;
data origin ;
 input d b c a;
cards;
1 2 3 4
;
run;
data output;
 input a b c d;
cards;
4 2 3 1
;
run;
proc sql ;
 select name into : list separated by ' '
&amp;nbsp; from dictionary.columns
&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='ORIGIN';
quit;
data want;
 retain &amp;amp;list;
 set output;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 08:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46568#M12413</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-03-28T08:47:57Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46569#M12414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the set of variables are the same then you can do it by referencing the original dataset first so that SAS "sees" the variables in that order first.&lt;/P&gt;&lt;P&gt;Use OBS=0 dataset option to prevent SAS from actually reading any observations from that source.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fixed ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set original(obs=0) have ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 11:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46569#M12414</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-28T11:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46570#M12415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice, Tom! Thank you for sharing!&lt;/P&gt;&lt;P&gt;Following Tom's lead, there are some other variants such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fixed;&lt;/P&gt;&lt;P&gt;merge origin (obs=0) output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fixed;&lt;/P&gt;&lt;P&gt;if 0 then set origin;&lt;/P&gt;&lt;P&gt;set output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or outrageously:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fixed;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash h(dataset: 'output', multidata:'y');&lt;/P&gt;&lt;P&gt; h.definekey(all:'y');&lt;/P&gt;&lt;P&gt; h.definedata(all:'y');&lt;/P&gt;&lt;P&gt; h.definedone();&lt;/P&gt;&lt;P&gt; dcl hiter hi('h');&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;set origin (obs=1);&lt;/P&gt;&lt;P&gt; do _n_=hi.first() by 0 while (_n_=0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt; _n_=hi.next();&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46570#M12415</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-28T12:02:49Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46571#M12416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Pls see question below in bold:&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;Ksharp wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;options user=work;
data origin ;
 input d b c a;
cards;
1 2 3 4
;
run;
data output;
 input a b c d;
cards;
4 2 3 1
;&lt;BR /&gt; run;
&lt;BR /&gt;&lt;STRONG&gt;Q: I have total 58 columns/variables, would the steps above very complicating by typing all the variables name and their sequence?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql ;
 select name into : list separated by ' '
&amp;nbsp; from dictionary.columns
&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='ORIGIN';
quit;
data want;
 retain &amp;amp;list;
 set output;
run;

&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Ksharp&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46571#M12416</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-03-28T12:22:31Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46572#M12417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what the question is.&lt;/P&gt;&lt;P&gt;If the question is would 58 variables be a problem? then no.&amp;nbsp; The macro variable LIST could hold hundreds or thousands of variable names.&lt;/P&gt;&lt;P&gt;If the quesiton is could you create the version with the variable names sorted by name then you can use the same method.&amp;nbsp; Just add an ORDER BY clause to the SQL query.&amp;nbsp; You could order by NAME to get alphabetical list.&amp;nbsp; You could order by VARPOS to match the physical order in the dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46572#M12417</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-28T12:30:28Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46573#M12418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Tom,&lt;/P&gt;&lt;P&gt;Forgive me if i ask stupid q, as i m not very familiar with sql..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my question is do i replace the ' d b c a ' with variables in my file? if yes, then i have to type all 58 variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options user=work;&lt;/P&gt;&lt;P&gt;data origin ;&lt;/P&gt;&lt;P&gt; input d b c a;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 2 3 4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data output;&lt;/P&gt;&lt;P&gt; input a b c d;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;4 2 3 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46573#M12418</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-03-28T12:36:38Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46574#M12419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;Tom wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the set of variables are the same then you can do it by referencing the original dataset first so that SAS "sees" the variables in that order first.&lt;/P&gt;&lt;P&gt;Use OBS=0 dataset option to prevent SAS from actually reading any observations from that source.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fixed ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set original(obs=0) have ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;hi Tom, just clarify, is this run first before running kSharp program?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46574#M12419</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-03-28T12:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46575#M12420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, you won't have to. It will be automatically done. Try it, and let us know how it goes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:38:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46575#M12420</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-28T12:38:55Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46576#M12421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, they are independent process, you choose to run ONLY one of them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46576#M12421</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-28T12:40:36Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46577#M12422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Those two data steps when posted as an example, since we do not know the structure of your actual datasets.&amp;nbsp; There is no need for you to type any variable names if you already have the two versions of the dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 15:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46577#M12422</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-28T15:41:41Z</dc:date>
    </item>
    <item>
      <title>rearranging variables back to the original datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46578#M12423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp，&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my stupidity to run the first part of data step and corrupt the data...i don't need to do it as i already have the datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;running from the pro sql give me the answer!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;mei&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 03:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rearranging-variables-back-to-the-original-datasets/m-p/46578#M12423</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-03-30T03:04:23Z</dc:date>
    </item>
  </channel>
</rss>

