<?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: SQL Into by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921339#M362841</link>
    <description>&lt;P&gt;This?&lt;/P&gt;
&lt;PRE&gt;data have;
	set cars;
	by make model;
	retain id_groups 0;
	if first.make then
		do;
			id_groups+1;
			id_value_groups=1;
		end;
	else
		do;
			id_value_groups+1;
		end;

   call symputx(catx('_','Make',id_groups,Id_value_groups),Model);
run;

%put &amp;amp;make_1_3;
%put &amp;amp;make_2_2;&lt;/PRE&gt;
&lt;P&gt;If the only purpose of the data step is to create the macro variables then use a DATA _NULL_ as you don't need the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where does SQL come into this? SQL doesn't use BY&amp;nbsp; groups per se.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 16:23:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-03-21T16:23:00Z</dc:date>
    <item>
      <title>SQL Into by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921333#M362838</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have-- have.sas7bdat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a list of macro variables in a way that when I invoke&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;want_1_3&lt;/STRONG&gt; i get MDX&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;want_2_2&lt;/STRONG&gt; i get A4 3.0 4dr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I proceed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data=sashelp.cars nodupkey out=cars(keep=make model);
	by make model;
run;

data have;
	set cars;
	by make model;
	retain id_groups 0;
	if first.make then
		do;
			id_groups+1;
			id_value_groups=1;
		end;
	else
		do;
			id_value_groups+1;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 16:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921333#M362838</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2024-03-21T16:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Into by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921339#M362841</link>
      <description>&lt;P&gt;This?&lt;/P&gt;
&lt;PRE&gt;data have;
	set cars;
	by make model;
	retain id_groups 0;
	if first.make then
		do;
			id_groups+1;
			id_value_groups=1;
		end;
	else
		do;
			id_value_groups+1;
		end;

   call symputx(catx('_','Make',id_groups,Id_value_groups),Model);
run;

%put &amp;amp;make_1_3;
%put &amp;amp;make_2_2;&lt;/PRE&gt;
&lt;P&gt;If the only purpose of the data step is to create the macro variables then use a DATA _NULL_ as you don't need the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where does SQL come into this? SQL doesn't use BY&amp;nbsp; groups per se.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 16:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921339#M362841</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-21T16:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Into by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921347#M362845</link>
      <description>&lt;P&gt;True. I dont know why I was thinking this can be done only by SQL. Thank You very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 17:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Into-by-groups/m-p/921347#M362845</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2024-03-21T17:08:15Z</dc:date>
    </item>
  </channel>
</rss>

