<?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: create a new data which include multiple variables by SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494628#M130378</link>
    <description>Dear Reeza, many thanks for your recommendation. I will read the paper in the future.</description>
    <pubDate>Tue, 11 Sep 2018 20:15:43 GMT</pubDate>
    <dc:creator>France</dc:creator>
    <dc:date>2018-09-11T20:15:43Z</dc:date>
    <item>
      <title>create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494615#M130370</link>
      <description>&lt;P&gt;Dear all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new data which include multiple&amp;nbsp;variables,&amp;nbsp; I cannot use * because&amp;nbsp;there are some variables I do not want to input.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE Step5.number_of_patent_us AS
SELECT 
  end.psn_name,
  &lt;STRONG&gt;application200001,
  application200002,
  application200003,
  ....
  application201012&lt;/STRONG&gt;

FROM Step5.ar_number_of_patent_end AS end
JOIN Pat_ori.Companies AS co ON end.psn_name = co.psn_name
WHERE person_ctry_code='US'
ORDER BY end.psn_name
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;could you please give me some suggestion? or&amp;nbsp;what should I do&amp;nbsp; if PROC SQL cannot work&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 19:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494615#M130370</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-11T19:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494617#M130371</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Use *&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;with a &lt;STRONG&gt;drop=&lt;/STRONG&gt; dataset option in the from clause like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; Step5&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;ar_number_of_patent_end(drop=var1 var2 var3....) AS end&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 19:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494617#M130371</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-11T19:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494618#M130372</link>
      <description>&lt;P&gt;A data step supports variable lists, whereas SQL does not.&amp;nbsp;&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/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a new data which include multiple&amp;nbsp;variables,&amp;nbsp; I cannot use * because&amp;nbsp;there are some variables I do not want to input.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE Step5.number_of_patent_us AS
SELECT 
  end.psn_name,
  &lt;STRONG&gt;application200001,
  application200002,
  application200003,
  ....
  application201012&lt;/STRONG&gt;

FROM Step5.ar_number_of_patent_end AS end
JOIN Pat_ori.Companies AS co ON end.psn_name = co.psn_name
WHERE person_ctry_code='US'
ORDER BY end.psn_name
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;could you please give me some suggestion? or&amp;nbsp;what should I do&amp;nbsp; if PROC SQL cannot work&lt;/P&gt;
&lt;P&gt;thanks in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 19:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494618#M130372</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-11T19:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494620#M130373</link>
      <description>On second thought, perhaps you should restructure your data first. Make it long rather than wide and it's much easier to work with. If you need some suggestions regarding data structures, I recommend the "Tidy Data" paper by Hadley Wickham. Although the code is in R, it's still the same principles.</description>
      <pubDate>Tue, 11 Sep 2018 19:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494620#M130373</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-11T19:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494624#M130376</link>
      <description>&lt;P&gt;You may select US patents and transpose your data with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create view ar_number_of_patent_us as
SELECT *
FROM    
    Step5.ar_number_of_patent_end AS end inner join
    Pat_ori.Companies AS co ON end.psn_name = co.psn_name
WHERE co.person_ctry_code='US';
QUIT;

data Step5.number_of_patent_us;
set ar_number_of_patent_us;
array a application200001 -- application201012;
do i = 1 to dim(a);
    y = substr(vname(a{i}), 12, 4);
    m = substr(vname(a{i}), 16, 2);
    month = mdy(input(m, best.), 1, input(y, best.));
    nbPatent = a{i};
    output;
    end;
format month yymmp.;
keep psn_name month nbPatent;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 20:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494624#M130376</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-11T20:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494625#M130377</link>
      <description>&lt;P&gt;dear novinosrin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please give me some suggestions if I want to delete all variables in pat_ori.Companies, and the reason I join this data set is I want use&amp;nbsp;the person_ctry_code in it to identify the US company.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, it seems that I cannot get the result after dropping&amp;nbsp;all&amp;nbsp;variables in&lt;SPAN&gt;&amp;nbsp;pat_ori.&lt;/SPAN&gt;Companies&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 20:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494625#M130377</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-11T20:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494628#M130378</link>
      <description>Dear Reeza, many thanks for your recommendation. I will read the paper in the future.</description>
      <pubDate>Tue, 11 Sep 2018 20:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494628#M130378</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-11T20:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: create a new data which include multiple variables by SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494635#M130383</link>
      <description>&lt;P&gt;If you only want data from a single table, use an alias with the *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select t1.* /*selects all data from t1 table*/
         , t2.country_code
from [table name] as t1
join [table name] as t2&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Sep 2018 21:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-new-data-which-include-multiple-variables-by-SQL/m-p/494635#M130383</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-11T21:02:57Z</dc:date>
    </item>
  </channel>
</rss>

