<?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 dynamically in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468282#M119587</link>
    <description>&lt;P&gt;Show some example output.&amp;nbsp; From what you post it sounds like you want to tranpose the data to something like:&lt;BR /&gt;subj101 subj102 subj103...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this use the proc transpose function, however I would also recommend not to work with transposed data as it increases the amount of code you will need to write to work with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for "&lt;/P&gt;
&lt;P&gt;and new dataset contain only subj values not idvar values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;"&lt;/P&gt;
&lt;P&gt;What does this mean?&amp;nbsp; Examples really help!&lt;/P&gt;
&lt;P&gt;Maybe:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (keep=subj);
run;

/* Or if from the transposed */
data want;
  set have (keep=subj:);
run;

/* Note the colon, meaning anything with prefix */&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Jun 2018 08:00:27 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-06-07T08:00:27Z</dc:date>
    <item>
      <title>Create variables dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468269#M119583</link>
      <description>&lt;P&gt;Hi All;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the data i have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input idvar subj ;
 datalines;
 1 101
 2 102
 3 103
 4 105
 5 106
 6 107
 7 111
 8 112
 ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to create new 4 variables as subj1 , subj2 ,subj3,subj4 containing two records each and new dataset contain only subj values not idvar values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please guide how can i keep it dynamic as next time&amp;nbsp; i do not need to check record count and new variable created automatically by sas program ?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 07:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468269#M119583</guid>
      <dc:creator>draroda</dc:creator>
      <dc:date>2018-06-07T07:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create variables dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468276#M119585</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input idvar subj ;
datalines;
1 101
2 102
3 103
4 105
5 106
6 107
7 111
8 112
;
run;

data int;
set have;
retain group 0;
if mod(idvar,4) = 1 then group + 1;
idvar = mod(idvar - 1,4) + 1;
run;

proc transpose
  data=int
  out=want (drop=group _name_)
  prefix=subj
;
by group;
var subj;
id idvar;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 07:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468276#M119585</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-07T07:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create variables dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468282#M119587</link>
      <description>&lt;P&gt;Show some example output.&amp;nbsp; From what you post it sounds like you want to tranpose the data to something like:&lt;BR /&gt;subj101 subj102 subj103...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this use the proc transpose function, however I would also recommend not to work with transposed data as it increases the amount of code you will need to write to work with it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for "&lt;/P&gt;
&lt;P&gt;and new dataset contain only subj values not idvar values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;"&lt;/P&gt;
&lt;P&gt;What does this mean?&amp;nbsp; Examples really help!&lt;/P&gt;
&lt;P&gt;Maybe:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (keep=subj);
run;

/* Or if from the transposed */
data want;
  set have (keep=subj:);
run;

/* Note the colon, meaning anything with prefix */&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 08:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variables-dynamically/m-p/468282#M119587</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-07T08:00:27Z</dc:date>
    </item>
  </channel>
</rss>

