<?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: access SQL through data. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794356#M32846</link>
    <description>&lt;P&gt;The code is correct, syntax wise, but logically incorrect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last data step will not do anything for example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code snippets don't seem to align, you create a table in mylib but then try and reference a data set in temp with the same name? However no input data set is provided.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can only offer a very broad suggestion to fix it because I don't know what you're trying to accomplish.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set mylib.test;

rename var1 = ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 Feb 2022 20:48:38 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-02-03T20:48:38Z</dc:date>
    <item>
      <title>access SQL through data.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794353#M32844</link>
      <description>&lt;P&gt;I've created a table on proc sql then tried to access it and adjust it through sas. it keeps giving me an empty output&lt;/P&gt;&lt;P&gt;I've used the following code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table mylib.test as&lt;BR /&gt;select *&lt;BR /&gt;from lib1.data1&lt;BR /&gt;where var2='202220'&lt;BR /&gt;order by var3, var4;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data temp.test;&lt;BR /&gt;rename var1=ID;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794353#M32844</guid>
      <dc:creator>Abdulla1</dc:creator>
      <dc:date>2022-02-03T20:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: access SQL through data.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794356#M32846</link>
      <description>&lt;P&gt;The code is correct, syntax wise, but logically incorrect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last data step will not do anything for example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code snippets don't seem to align, you create a table in mylib but then try and reference a data set in temp with the same name? However no input data set is provided.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can only offer a very broad suggestion to fix it because I don't know what you're trying to accomplish.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set mylib.test;

rename var1 = ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 20:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794356#M32846</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-03T20:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: access SQL through data.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794361#M32847</link>
      <description>&lt;P&gt;Thanks that works very well.&lt;/P&gt;&lt;P&gt;however, I'm trying to change the variable var1 into ID can I do that without setting new variable&lt;/P&gt;&lt;P&gt;I tried the code below but it didn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table mylib.test as&lt;BR /&gt;select *&lt;BR /&gt;from lib1.data1&lt;BR /&gt;where var2='202220'&lt;BR /&gt;order by var3, var4;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data mylib.test;&lt;BR /&gt;rename var1=ID;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 21:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794361#M32847</guid>
      <dc:creator>Abdulla1</dc:creator>
      <dc:date>2022-02-03T21:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: access SQL through data.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794362#M32848</link>
      <description>&lt;P&gt;You have no &lt;STRONG&gt;SET&lt;/STRONG&gt; statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A &lt;STRONG&gt;SET&lt;/STRONG&gt; statement tells SAS what the &lt;STRONG&gt;input&lt;/STRONG&gt; data set is. Since there is none,&amp;nbsp; there is no data to work with in that step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step actually deletes your initial step and replaces that data with nothing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is probably what you want but not a good idea. Whenever you have a data step its not a good idea to have your SET and DATA reference the same data set. This destroys your original data set so if you make a mistake you have to go back extra steps.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mylib.test;
set mylib.test;

rename var1 = ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead you can build on it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mylib.test2;
set mylib.test;

rename var1 = ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use PROC DATASETS to rename the variable. This is actually the fastest, most efficient option as it just changes the metadata/variable name. In a Data step or SQL proc it actually go through all the data and recreates a new data set at the end.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=mylib;
modify test;
rename var1=id;
run;quit;&lt;/CODE&gt;&lt;/PRE&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/414636"&gt;@Abdulla1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks that works very well.&lt;/P&gt;
&lt;P&gt;however, I'm trying to change the variable var1 into ID can I do that without setting new variable&lt;/P&gt;
&lt;P&gt;I tried the code below but it didn't work either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table mylib.test as&lt;BR /&gt;select *&lt;BR /&gt;from lib1.data1&lt;BR /&gt;where var2='202220'&lt;BR /&gt;order by var3, var4;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;data mylib.test;&lt;BR /&gt;rename var1=ID;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 21:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794362#M32848</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-03T21:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: access SQL through data.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794367#M32849</link>
      <description>&lt;P&gt;thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that is very helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 22:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/access-SQL-through-data/m-p/794367#M32849</guid>
      <dc:creator>Abdulla1</dc:creator>
      <dc:date>2022-02-03T22:17:13Z</dc:date>
    </item>
  </channel>
</rss>

