<?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: Using &amp;amp; variable to automate CAT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729531#M227036</link>
    <description>&lt;P&gt;But how did you get to have multiple "student" variables to begin with?&lt;/P&gt;
&lt;P&gt;Why isn't the data organized to have one variable for student and multiple observations if there are multiple students?&lt;/P&gt;</description>
    <pubDate>Sat, 27 Mar 2021 03:39:22 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-03-27T03:39:22Z</dc:date>
    <item>
      <title>Using &amp; variable to automate CAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729426#M226979</link>
      <description>&lt;P&gt;Hi! I'm trying to automate a piece of code that works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to list all the students who did an activity, but I need to report this on a list within my current table. So, I use the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data students_list;
set WORK.students;
SP='; ';
students=catx(sp, of STUDENT_1-STUDENT_45);
run;

PROC SQL;
Create Table final as
select t1.*, t2.students from activity t1, students_list t2;
Quit;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I don't want to have to indicate the number of students manually, as this has caused me to generate many errors. So I'm trying to do it with the following code, but it's not working. Can someone help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attempt using &amp;amp;n_students:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;PROC SQL noprint;
	SELECT  count(*) 
	INTO :n_students
	FROM WORK.class_activity;
	QUIT;

data students_list;
set WORK.students;
SP='; ';
students=catx(sp, of STUDENT_1-STUDENT_&amp;amp;n_students);
run;

PROC SQL;
Create Table final as
select t1.*, t2.students from activity t1, students_list t2;
Quit;&lt;/LI-CODE&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>Fri, 26 Mar 2021 15:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729426#M226979</guid>
      <dc:creator>Neeydchi</dc:creator>
      <dc:date>2021-03-26T15:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using &amp; variable to automate CAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729433#M226984</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;students=catx(sp, of STUDENT_:);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Depends on your naming structure to some degree. This blog post covers some of the options and how they work:&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/375668"&gt;@Neeydchi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi! I'm trying to automate a piece of code that works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My goal is to list all the students who did an activity, but I need to report this on a list within my current table. So, I use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data students_list;
set WORK.students;
SP='; ';
students=catx(sp, of STUDENT_1-STUDENT_45);
run;

PROC SQL;
Create Table final as
select t1.*, t2.students from activity t1, students_list t2;
Quit;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I don't want to have to indicate the number of students manually, as this has caused me to generate many errors. So I'm trying to do it with the following code, but it's not working. Can someone help me?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attempt using &amp;amp;n_students:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;PROC SQL noprint;
	SELECT  count(*) 
	INTO :n_students
	FROM WORK.class_activity;
	QUIT;

data students_list;
set WORK.students;
SP='; ';
students=catx(sp, of STUDENT_1-STUDENT_&amp;amp;n_students);
run;

PROC SQL;
Create Table final as
select t1.*, t2.students from activity t1, students_list t2;
Quit;&lt;/LI-CODE&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;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 15:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729433#M226984</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-26T15:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using &amp; variable to automate CAT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729531#M227036</link>
      <description>&lt;P&gt;But how did you get to have multiple "student" variables to begin with?&lt;/P&gt;
&lt;P&gt;Why isn't the data organized to have one variable for student and multiple observations if there are multiple students?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 03:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-amp-variable-to-automate-CAT/m-p/729531#M227036</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-27T03:39:22Z</dc:date>
    </item>
  </channel>
</rss>

