<?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: How do I create a data set from a list of row and column positions? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789247#M252525</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data start;
input r c;
datalines;
1 1
2 3
3 4
;
run;

proc sql noprint;
select max(max(r,c)) into :size
from start;
quit;

proc sort data = start;
  by r c;
run;

data want;
  set start end=eof;
  by r c;

  array x[&amp;amp;size.];

  if first.r then 
    do _N_ = 1 to &amp;amp;size.;
      x[_N_]=0;  
    end;

  x[c] = 1;

  if last.r then 
    do;
      output;
      r_count + 1;
    end;
  keep x:;
  if eof and r_count NE &amp;amp;size. then
    do;
      do _N_ = 1 to &amp;amp;size.;
        x[_N_]=0;  
      end;

      do _N_ = r_count+1 to &amp;amp;size.;
        output;
      end;
    end;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jan 2022 13:24:35 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2022-01-10T13:24:35Z</dc:date>
    <item>
      <title>How do I create a data set from a list of row and column positions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789238#M252516</link>
      <description>&lt;P&gt;I have a list of row and column pairs. I would like to create a new dataset such that each row/column pair from the list is assigned a value of 1, otherwise a value of zero.&lt;/P&gt;
&lt;PRE&gt;data start;
input r c;
datalines;
1 1
2 3
3 4
;
run;&lt;/PRE&gt;
&lt;P&gt;I would like to end up with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 0 0 0&lt;/P&gt;
&lt;P&gt;0 0 1 0&lt;/P&gt;
&lt;P&gt;0 0 0 1&lt;/P&gt;
&lt;P&gt;0 0 0 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot use PROC IML because my actual dataset is too large and I do not have enough memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 12:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789238#M252516</guid>
      <dc:creator>fpb1</dc:creator>
      <dc:date>2022-01-10T12:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a data set from a list of row and column positions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789241#M252519</link>
      <description>&lt;P&gt;Can you back up and give us a broader picture of what this problem is? There are other ways of creating columns of zeros and ones that don't require PROC IML, if only we knew what you are doing we might be able to recommend some other way.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 13:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789241#M252519</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-10T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a data set from a list of row and column positions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789242#M252520</link>
      <description>&lt;P&gt;It is IML things. Hope you have SAS/IML .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data start;
input r c;
v=1;
datalines;
1 1
2 3
3 4
;
run;


proc iml;
use start;
read all var{v r c} into x;
close;
want=full(x);
create want from want;
append from want;
close;
quit;


proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 13:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789242#M252520</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-10T13:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a data set from a list of row and column positions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789245#M252523</link>
      <description>&lt;P&gt;If you really want data step , try this one :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data start;
input r c;
datalines;
1 1
2 3
3 4
;
run;


%let nrow=4;
%let ncol=4;
data want;
 if _n_=1 then do;
  if 0 then set start;
  declare hash h(dataset:'start');
  h.definekey('r','c');
  h.definedone();
 end;

array x{&amp;amp;ncol.};

do r=1 to &amp;amp;nrow.;
do c=1 to &amp;amp;ncol.;
 if h.check()=0 then x{c}=1;
  else x{c}=0;
end;
output;
end;

keep x:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 13:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789245#M252523</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-10T13:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a data set from a list of row and column positions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789247#M252525</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data start;
input r c;
datalines;
1 1
2 3
3 4
;
run;

proc sql noprint;
select max(max(r,c)) into :size
from start;
quit;

proc sort data = start;
  by r c;
run;

data want;
  set start end=eof;
  by r c;

  array x[&amp;amp;size.];

  if first.r then 
    do _N_ = 1 to &amp;amp;size.;
      x[_N_]=0;  
    end;

  x[c] = 1;

  if last.r then 
    do;
      output;
      r_count + 1;
    end;
  keep x:;
  if eof and r_count NE &amp;amp;size. then
    do;
      do _N_ = 1 to &amp;amp;size.;
        x[_N_]=0;  
      end;

      do _N_ = r_count+1 to &amp;amp;size.;
        output;
      end;
    end;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 13:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789247#M252525</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-10T13:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a data set from a list of row and column positions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789251#M252528</link>
      <description>This worked perfectly, thank you. The IML solution as well, but as I mentioned, my data are too large for it.</description>
      <pubDate>Mon, 10 Jan 2022 13:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-data-set-from-a-list-of-row-and-column/m-p/789251#M252528</guid>
      <dc:creator>fpb1</dc:creator>
      <dc:date>2022-01-10T13:56:04Z</dc:date>
    </item>
  </channel>
</rss>

