<?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: Subsetting a SAS dataset and saving it as an RDS with proc iml in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958144#M6421</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data heights_weights;
    input Name $ Height Weight second_group $;
    datalines;
J 70 180 D
J 65 140 D
K 68 150 S
K 72 200 D
K 66 130 S
L 74 210 S
L 64 135 S
L 69 175 D
J 67 145 D
K 71 190 D
L 63 125 D
J 73 205 D
L 62 120 D
K 75 220 D
K 70 160 D
;
run;
 
proc iml;
use heights_weights;
read all var {Name} ;
close;
levels=unique(name); 
do i=1 to ncol(levels);
  use heights_weights;
  read all var _num_ where(name=(levels[i])) into num[c=vname1] ;
  read all var _char_ where(name=(levels[i])) into char[c=vname2] ;
  close;
  create (levels[i]) from num char[c=(vname1||vname2)];
  append from num char;
  close;
/*call exportmatrixtor(nhw, "nhw");
submit nhw letter_name/R;
...................
endsubmit
*/
end;
quit;

proc print data=J noobs;run;
proc print data=K noobs;run;
proc print data=L noobs;run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Feb 2025 01:53:51 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-02-04T01:53:51Z</dc:date>
    <item>
      <title>Subsetting a SAS dataset and saving it as an RDS with proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958133#M6420</link>
      <description>&lt;P&gt;I am struggling to understand the proper way to subset a dataset for use in proc iml. My goal is to take a large sas dataset (6,000,000x1,500) and save it as multiple smaller RDS datasets using proc iml based on a grouping variable.&amp;nbsp; My issue is that submit cannot be used in a macro and the use and read statements only keep the numeric variables. Is there a way to keep all variables, numeric and character in the dataset? Below is a small example of the code I have at the moment.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;%let names = J K L;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data heights_weights;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; input Name $ Height Weight second_group $;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; datalines;&lt;/DIV&gt;&lt;DIV&gt;J 70 180 D&lt;/DIV&gt;&lt;DIV&gt;J 65 140 D&lt;/DIV&gt;&lt;DIV&gt;K 68 150 S&lt;/DIV&gt;&lt;DIV&gt;K 72 200 D&lt;/DIV&gt;&lt;DIV&gt;K 66 130 S&lt;/DIV&gt;&lt;DIV&gt;L 74 210 S&lt;/DIV&gt;&lt;DIV&gt;L 64 135 S&lt;/DIV&gt;&lt;DIV&gt;L 69 175 D&lt;/DIV&gt;&lt;DIV&gt;J 67 145 D&lt;/DIV&gt;&lt;DIV&gt;K 71 190 D&lt;/DIV&gt;&lt;DIV&gt;L 63 125 D&lt;/DIV&gt;&lt;DIV&gt;J 73 205 D&lt;/DIV&gt;&lt;DIV&gt;L 62 120 D&lt;/DIV&gt;&lt;DIV&gt;K 75 220 D&lt;/DIV&gt;&lt;DIV&gt;K 70 160 D&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc iml;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;do i=1 to countw("&amp;amp;names");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;letter_name = scan("&amp;amp;names",i);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;use heights_weights where(Name = letter_name);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;read all into nhw;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;close heights_weights;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;call exportmatrixtor(nhw, "nhw");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;submit nhw letter_name/R;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print(paste("dataset","&amp;amp;letter_name"))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print(nhw)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# saveRDS(nhw, paste("nhw","&amp;amp;letter_name",".rds"))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;endsubmit;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 22:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958133#M6420</guid>
      <dc:creator>Coreyw184</dc:creator>
      <dc:date>2025-02-03T22:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting a SAS dataset and saving it as an RDS with proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958144#M6421</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data heights_weights;
    input Name $ Height Weight second_group $;
    datalines;
J 70 180 D
J 65 140 D
K 68 150 S
K 72 200 D
K 66 130 S
L 74 210 S
L 64 135 S
L 69 175 D
J 67 145 D
K 71 190 D
L 63 125 D
J 73 205 D
L 62 120 D
K 75 220 D
K 70 160 D
;
run;
 
proc iml;
use heights_weights;
read all var {Name} ;
close;
levels=unique(name); 
do i=1 to ncol(levels);
  use heights_weights;
  read all var _num_ where(name=(levels[i])) into num[c=vname1] ;
  read all var _char_ where(name=(levels[i])) into char[c=vname2] ;
  close;
  create (levels[i]) from num char[c=(vname1||vname2)];
  append from num char;
  close;
/*call exportmatrixtor(nhw, "nhw");
submit nhw letter_name/R;
...................
endsubmit
*/
end;
quit;

proc print data=J noobs;run;
proc print data=K noobs;run;
proc print data=L noobs;run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2025 01:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958144#M6421</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-04T01:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting a SAS dataset and saving it as an RDS with proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958145#M6422</link>
      <description>You could try new data structure of IML:&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/imlcdc/14.2/imlug/imlug_tables_toc.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/imlcdc/14.2/imlug/imlug_tables_toc.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/03/29/lists-sasiml.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/03/29/lists-sasiml.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/01/22/iml-lists-syntax.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/01/22/iml-lists-syntax.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/03/22/data-tables-in-sasiml.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/03/22/data-tables-in-sasiml.html&lt;/A&gt;</description>
      <pubDate>Tue, 04 Feb 2025 02:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Subsetting-a-SAS-dataset-and-saving-it-as-an-RDS-with-proc-iml/m-p/958145#M6422</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-04T02:08:45Z</dc:date>
    </item>
  </channel>
</rss>

