<?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: SAS dataset into a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921790#M362989</link>
    <description>&lt;P&gt;The simplest way to make a macro variable from data is using PROC SQL and in the INTO keyword.&lt;/P&gt;
&lt;P&gt;So to make a macro variable named LIST from the values of ID in the dataset HAVE you could use something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct quote(trim(ID),"'") into :list separated by ',' 
  from have
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What to you plan to DO with the macro variable?&amp;nbsp; Do you really need the commas?&amp;nbsp; The IN operator in SAS does not mind if you use spaces instead of commas between the items in the list.&amp;nbsp; Spaces in macro variables are much easier to work with than commas.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2024 13:48:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-03-26T13:48:10Z</dc:date>
    <item>
      <title>SAS dataset into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921785#M362986</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a sas work dataset as below ( only one column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;34&lt;/P&gt;&lt;P&gt;56&lt;/P&gt;&lt;P&gt;78&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to assign these ID's again into a single variable as like below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let = "12","34","56","78";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with catx funtion to convert multiple rows into single row but didnot help. Please help me to achieve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 13:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921785#M362986</guid>
      <dc:creator>freshstarter</dc:creator>
      <dc:date>2024-03-26T13:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dataset into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921787#M362987</link>
      <description>&lt;P&gt;Why do you need this? What is the benefit? What will you do next once you have this variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, are you talking about a MACRO variable? You didn't actually say that, but you use %LET.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 13:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921787#M362987</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-26T13:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dataset into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921789#M362988</link>
      <description>&lt;P&gt;Is the value of ID duplicated in the data set?&lt;/P&gt;
&lt;P&gt;If so should there be two or more copies in the data set?&lt;/P&gt;
&lt;P&gt;Does the order of the values have to match the order they appear in the data set?&lt;/P&gt;
&lt;P&gt;Is the variable numeric or character?&lt;/P&gt;
&lt;P&gt;How many values are we talking about? There is a limit on the number of characters in a macro variable and adding basically 3 characters for each value means you start cutting into the number of values that will even fit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost every time we see a "place all the values of a variable in a data set into a macro variable" we see a follow up with attempts to use that variable in a manner that is very inefficient, cumbersome or just plain fails. So a clear description of what is to be done with this may be more helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 13:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921789#M362988</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-26T13:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dataset into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921790#M362989</link>
      <description>&lt;P&gt;The simplest way to make a macro variable from data is using PROC SQL and in the INTO keyword.&lt;/P&gt;
&lt;P&gt;So to make a macro variable named LIST from the values of ID in the dataset HAVE you could use something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct quote(trim(ID),"'") into :list separated by ',' 
  from have
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What to you plan to DO with the macro variable?&amp;nbsp; Do you really need the commas?&amp;nbsp; The IN operator in SAS does not mind if you use spaces instead of commas between the items in the list.&amp;nbsp; Spaces in macro variables are much easier to work with than commas.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 13:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921790#M362989</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-26T13:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dataset into a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921797#M362993</link>
      <description>&lt;P&gt;Thanks All for the suggestion. didnot realise proc sql has an easy way out.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 14:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dataset-into-a-variable/m-p/921797#M362993</guid>
      <dc:creator>freshstarter</dc:creator>
      <dc:date>2024-03-26T14:46:15Z</dc:date>
    </item>
  </channel>
</rss>

