<?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: Creating new dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361518#M85277</link>
    <description>&lt;P&gt;First suggestion would be to follow the guidance provided un the Post button n the new question page, and in the pop up which appears. &amp;nbsp;Post your test data in the form of a dataste (not done), and what the output shoudl look like. &amp;nbsp;Then clearly explain the logic between the two. &amp;nbsp;Why does B and C appear as 1 in col2 but D in col3? &amp;nbsp;There is no logical reason for this that I can see other than scheme=TVF=1, OPJ=2, JKP=3. &amp;nbsp;If that is indeed the case, then maybe clarify that simple by using a proc transpose (assumes sorted, and not tested as I am not here to type in test data):&lt;/P&gt;
&lt;PRE&gt;proc transpose data=have out=want;
  by no name age;
  var scheme;
  idlabel scheme;
run;&lt;/PRE&gt;
&lt;P&gt;This should create col1-3, with the label showing the scheme data, however if not sorted, you have multiples etc then it will fail. &amp;nbsp;If you need them in a particular order, then add to the data that order number, and use that as id &amp;lt;ordernumber&amp;gt;;&lt;/P&gt;</description>
    <pubDate>Thu, 25 May 2017 09:56:06 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-25T09:56:06Z</dc:date>
    <item>
      <title>Creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361515#M85274</link>
      <description>&lt;P&gt;I have data which contain&amp;nbsp;&lt;/P&gt;&lt;P&gt;No. Name Age Scheme&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 35 &amp;nbsp; &amp;nbsp; &amp;nbsp;TVF&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21 &amp;nbsp; &amp;nbsp; &amp;nbsp;OPJ&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 54 &amp;nbsp; &amp;nbsp; &amp;nbsp;OPJ&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 63 &amp;nbsp; &amp;nbsp; JKP&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 35 &amp;nbsp; &amp;nbsp; JKP&lt;/P&gt;&lt;P&gt;and now I want in this type&lt;BR /&gt;i.e.&lt;BR /&gt;if Name is repeated then that scheme flag(1 or 0) will be separate into a new column&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;like this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No.Name Age &amp;nbsp; &amp;nbsp; &amp;nbsp;TVF OPJ JKP&lt;BR /&gt;&amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;35 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;&amp;nbsp;2 &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;21 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;&amp;nbsp;3 &amp;nbsp; &amp;nbsp; C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;54 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;&amp;nbsp;4 &amp;nbsp; &amp;nbsp; D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;63 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please give me a suggestion&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&amp;nbsp;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 11:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361515#M85274</guid>
      <dc:creator>india2016</dc:creator>
      <dc:date>2017-05-25T11:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361518#M85277</link>
      <description>&lt;P&gt;First suggestion would be to follow the guidance provided un the Post button n the new question page, and in the pop up which appears. &amp;nbsp;Post your test data in the form of a dataste (not done), and what the output shoudl look like. &amp;nbsp;Then clearly explain the logic between the two. &amp;nbsp;Why does B and C appear as 1 in col2 but D in col3? &amp;nbsp;There is no logical reason for this that I can see other than scheme=TVF=1, OPJ=2, JKP=3. &amp;nbsp;If that is indeed the case, then maybe clarify that simple by using a proc transpose (assumes sorted, and not tested as I am not here to type in test data):&lt;/P&gt;
&lt;PRE&gt;proc transpose data=have out=want;
  by no name age;
  var scheme;
  idlabel scheme;
run;&lt;/PRE&gt;
&lt;P&gt;This should create col1-3, with the label showing the scheme data, however if not sorted, you have multiples etc then it will fail. &amp;nbsp;If you need them in a particular order, then add to the data that order number, and use that as id &amp;lt;ordernumber&amp;gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 09:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361518#M85277</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-25T09:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361546#M85291</link>
      <description>&lt;P&gt;you are trying to get design matrix .&lt;/P&gt;
&lt;P&gt;1) IML code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input No Name $ Age Scheme $;
cards;
1    A         35      TVF
2    B         21      OPJ
3    C         54      OPJ
4    D         63     JKP
5    A         35     JKP
;
run;

proc iml;
use have;
read all var{scheme};
close;
vname=unique(scheme);
design=design(scheme);
create want from design[c=vname];
append from design;
close;
quit;
data want;
 merge have want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) PROC to get design matrix&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input No Name $ Age Scheme $;
cards;
1    A         35      TVF
2    B         21      OPJ
3    C         54      OPJ
4    D         63     JKP
5    A         35     JKP
;
run;

data have;
 set have;
 dummy=1;
run;
proc logistic data=have outdesign=design outdesignonly;
class scheme/ param=glm;
model dummy=scheme;
run;
data want;
 merge have design(drop=dummy intercept);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 May 2017 12:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361546#M85291</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-25T12:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361604#M85316</link>
      <description>&lt;P&gt;Close to what you ask, and relatively easy to get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by name age;&lt;/P&gt;
&lt;P&gt;run;&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;x=1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=have2;&lt;/P&gt;
&lt;P&gt;by name age;&lt;/P&gt;
&lt;P&gt;var x;&lt;/P&gt;
&lt;P&gt;id scheme;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gets rid of the first column (No.), but you can always add that later.&amp;nbsp; And it leaves variables with a missing value instead of a 0 (again, you can always fix that later if you need to).&amp;nbsp; But it produces the right variables, and assigns them a value of 1 in the proper cases.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 13:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-dataset/m-p/361604#M85316</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-25T13:59:35Z</dc:date>
    </item>
  </channel>
</rss>

