<?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: Data step IF/THEN value change in SQL? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76726#M22252</link>
    <description>Hi Daniel-  &lt;BR /&gt;
&lt;BR /&gt;
That's where I was in the documentation, but it was unclear how to specify no change.&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much for your help!  &lt;BR /&gt;
&lt;BR /&gt;
Wendy</description>
    <pubDate>Mon, 26 Oct 2009 16:37:38 GMT</pubDate>
    <dc:creator>WendyT</dc:creator>
    <dc:date>2009-10-26T16:37:38Z</dc:date>
    <item>
      <title>Data step IF/THEN value change in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76724#M22250</link>
      <description>Currently, I have a datastep that accesses a very large table, and it must later be sorted by three variables, which takes forever. &lt;BR /&gt;
&lt;BR /&gt;
DATA SAMPLES_DATA ; &lt;BR /&gt;
SET DATABASE.SAMPLES (RENAME=(SMPL_ID=SAMP_NUM STN_NM=STATION ANLYT_NM=ANALYTE)) ;&lt;BR /&gt;
IF PROJ_NM ='Project 1 old name' then PROJ_NM =’Project 1 new name' ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
…later on…&lt;BR /&gt;
PROC SORT DATA=DATABASE.SAMPLES ; BY SAMP_NUM ANALYTE STATION ; RUN ;&lt;BR /&gt;
&lt;BR /&gt;
I’m trying to come up with a solution using SQL, so I can use an ORDER BY that runs much faster.&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL NOPRINT ;&lt;BR /&gt;
CREATE TABLE SAMPLES_SQL &lt;BR /&gt;
AS SELECT *,&lt;BR /&gt;
SMPL_ID AS SAMP_NUM,&lt;BR /&gt;
STN_NM AS STATION,&lt;BR /&gt;
ANLYT_NM AS ANALYTE&lt;BR /&gt;
FROM DATABASE.SAMPLES&lt;BR /&gt;
ORDER BY SAMP_NUM, ANALYTE, STATION ;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
However, I’m stumped as how to change the name of Project 1 in PROC SQL.  I played with the CASE statement, but if I understand the documentation correctly, all values of PROJ_NM have to be represented.  There are lots of projects, with new ones added on a fairly frequent basis, so that’s not a very good solution.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for any advice you can give me.&lt;BR /&gt;
&lt;BR /&gt;
Wendy T.</description>
      <pubDate>Mon, 26 Oct 2009 15:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76724#M22250</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2009-10-26T15:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data step IF/THEN value change in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76725#M22251</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
The CASE statement works exactly as the IF statement.&lt;BR /&gt;
&lt;BR /&gt;
IF PROJ_NM ='Project 1 old name' then PROJ_NM =’Project 1 new name' ;&lt;BR /&gt;
&lt;BR /&gt;
Would translate to:&lt;BR /&gt;
&lt;BR /&gt;
CASE WHEN PROJ_NM ='Project 1 old name' THEN ’Project 1 new name' ELSE PROJ_NM END AS PROJ_NM&lt;BR /&gt;
&lt;BR /&gt;
Check the online doc here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473682.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473682.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Mon, 26 Oct 2009 15:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76725#M22251</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-10-26T15:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Data step IF/THEN value change in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76726#M22252</link>
      <description>Hi Daniel-  &lt;BR /&gt;
&lt;BR /&gt;
That's where I was in the documentation, but it was unclear how to specify no change.&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much for your help!  &lt;BR /&gt;
&lt;BR /&gt;
Wendy</description>
      <pubDate>Mon, 26 Oct 2009 16:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76726#M22252</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2009-10-26T16:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data step IF/THEN value change in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76727#M22253</link>
      <description>You may want to consider using a SAS PROC FORMAT to maintain the changes to your variable.  The PUT function would be used with your SELECT and SAS variable specification.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 26 Oct 2009 16:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-step-IF-THEN-value-change-in-SQL/m-p/76727#M22253</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-10-26T16:51:51Z</dc:date>
    </item>
  </channel>
</rss>

