<?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: create variables from observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321687#M71087</link>
    <description>&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name : $20.;
cards;
brand
colour
year
maxspeed
;
run;
proc transpose data=have out=want;
id name;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Dec 2016 03:53:23 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-12-30T03:53:23Z</dc:date>
    <item>
      <title>create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321624#M71059</link>
      <description>Hello.&lt;BR /&gt;&lt;BR /&gt;I have a dataset with only one variable and 50 observations. The variable contains names of other I want to use to create a new dataset. Of course, these names change, depending on the steps of the processing.&lt;BR /&gt;&lt;BR /&gt;Example of the dataset_1:&lt;BR /&gt;&lt;BR /&gt;variable_name&lt;BR /&gt;--------------------&lt;BR /&gt;brand&lt;BR /&gt;colour&lt;BR /&gt;year&lt;BR /&gt;maxspeed&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The new dataset to create, dynamicaly and empty, must have the following variables:&lt;BR /&gt;&lt;BR /&gt;Example of dataset_2:&lt;BR /&gt;&lt;BR /&gt;brand colour year maxspeed&lt;BR /&gt;------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;This is some kind of transpose. I tried some transposes but it didn't work out.&lt;BR /&gt;&lt;BR /&gt;Can someone help?&lt;BR /&gt;Thanks a lot.</description>
      <pubDate>Thu, 29 Dec 2016 19:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321624#M71059</guid>
      <dc:creator>rmlmrmlm</dc:creator>
      <dc:date>2016-12-29T19:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321626#M71061</link>
      <description>&lt;P&gt;You need more information in your first dataset, not just names: variable type, length, formats, ...&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 19:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321626#M71061</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-29T19:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321627#M71062</link>
      <description>Important: It's not possible to use the select variable into :var separated by ' ' because sometime we have so many columns that concatenated it exceeds the max lengrh of a macro variable.</description>
      <pubDate>Thu, 29 Dec 2016 19:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321627#M71062</guid>
      <dc:creator>rmlmrmlm</dc:creator>
      <dc:date>2016-12-29T19:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321629#M71063</link>
      <description>Yes, you are right! I didn' think about it. SAS rookie.</description>
      <pubDate>Thu, 29 Dec 2016 19:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321629#M71063</guid>
      <dc:creator>rmlmrmlm</dc:creator>
      <dc:date>2016-12-29T19:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321631#M71064</link>
      <description>Well ... I was checking ... In real life, the variables are all numeric.&lt;BR /&gt;&lt;BR /&gt;Can I use a kind of transpose, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;?</description>
      <pubDate>Thu, 29 Dec 2016 19:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321631#M71064</guid>
      <dc:creator>rmlmrmlm</dc:creator>
      <dc:date>2016-12-29T19:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321634#M71065</link>
      <description>&lt;P&gt;You only have one column? What would be in the variables created, missing? A full example would be helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 20:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321634#M71065</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-29T20:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321637#M71067</link>
      <description>&lt;P&gt;Here's a transpose approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have2;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;num_var = 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc transpose data=have2 out=want1 (drop=_name_ _label_);&lt;/P&gt;
&lt;P&gt;var num_var;&lt;/P&gt;
&lt;P&gt;id variable_name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;data want2;&lt;/P&gt;
&lt;P&gt;set want1;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The transpose creates all the numeric variables with a value of 1. &amp;nbsp;The final DATA step removes that observation, but leaves the variable definitions in place.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 20:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321637#M71067</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-29T20:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321638#M71068</link>
      <description>&lt;P&gt;You can do it in one step, assumed &lt;STRONG&gt;all variables are numeric&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _NULL_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; infile datalines truncover;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; input vname $;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if _N_ = 1 then call exceute('data test; &amp;nbsp;&lt;STRONG&gt;length &amp;nbsp;&lt;/STRONG&gt;');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if vname ne '===' &amp;nbsp; &amp;nbsp; &amp;nbsp; /* input data assigned to end of input */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; then call execeute('strip(vname) || ' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else call excecute(' &lt;STRONG&gt;8&lt;/STRONG&gt;; delete; run;');&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;brand&lt;/P&gt;
&lt;P&gt;colour&lt;/P&gt;
&lt;P&gt;year&lt;/P&gt;
&lt;P&gt;maxspeed&lt;/P&gt;
&lt;P&gt;===&lt;/P&gt;
&lt;P&gt;; run;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 20:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321638#M71068</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-29T20:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321644#M71070</link>
      <description>&lt;P&gt;You can also use a temporary file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename toto temp;

data _null_;
set have;
file toto;
put variable_name "=0;";
run;

data have;
%include toto;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Dec 2016 20:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321644#M71070</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-12-29T20:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321687#M71087</link>
      <description>&lt;P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name : $20.;
cards;
brand
colour
year
maxspeed
;
run;
proc transpose data=have out=want;
id name;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 03:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321687#M71087</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-30T03:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321746#M71105</link>
      <description>For my needs, this answer is valid.&lt;BR /&gt;Thanks.</description>
      <pubDate>Fri, 30 Dec 2016 15:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/321746#M71105</guid>
      <dc:creator>rmlmrmlm</dc:creator>
      <dc:date>2016-12-30T15:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: create variables from observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/322611#M71395</link>
      <description>&lt;P&gt;Thanks for this useful answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's working.! Kudos to you.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 08:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-variables-from-observations/m-p/322611#M71395</guid>
      <dc:creator>gk6565</dc:creator>
      <dc:date>2017-01-05T08:58:08Z</dc:date>
    </item>
  </channel>
</rss>

