<?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: Proc SQL, recode and convert variable from numeric to text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952170#M372147</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/471417"&gt;@Hali2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to retain the same variable name patientid, since i dont know how to retain in tt1, created tt2.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You wouldn't first DROP patientID and then in another SQL retain it. This should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
     create table tt as
     select *, cat("patient ",patientid) as patientid1 from Temp;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I question the value of adding text in front of a numeric variable like Patient ID. Seems unnecessary to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Nov 2024 13:10:51 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-11-29T13:10:51Z</dc:date>
    <item>
      <title>Proc SQL, recode and convert variable from numeric to text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952153#M372143</link>
      <description>&lt;P&gt;I am new to SAS and want to know if there is a way to do the following.&lt;/P&gt;&lt;P&gt;Import the excel file, and import all the variables. One variable is numeric, want to prefix a text to it as below. Can the code be simplified?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create table tt (drop = patientid) as&lt;BR /&gt;select *, cat("patient ",patientid) as patientid1 from Temp ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;create table tt2 (drop = patientid1) as&lt;BR /&gt;select *, patientid1 as patientid from tt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 08:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952153#M372143</guid>
      <dc:creator>Hali2</dc:creator>
      <dc:date>2024-11-29T08:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL, recode and convert variable from numeric to text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952162#M372144</link>
      <description>&lt;P&gt;What is the purpose of creating data set TT2? It seems you have everything you need in data set TT1. Please explain further.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 10:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952162#M372144</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-29T10:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL, recode and convert variable from numeric to text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952166#M372145</link>
      <description>&lt;P&gt;I want to retain the same variable name patientid, since i dont know how to retain in tt1, created tt2.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 12:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952166#M372145</guid>
      <dc:creator>Hali2</dc:creator>
      <dc:date>2024-11-29T12:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL, recode and convert variable from numeric to text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952170#M372147</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/471417"&gt;@Hali2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I want to retain the same variable name patientid, since i dont know how to retain in tt1, created tt2.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You wouldn't first DROP patientID and then in another SQL retain it. This should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
     create table tt as
     select *, cat("patient ",patientid) as patientid1 from Temp;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I question the value of adding text in front of a numeric variable like Patient ID. Seems unnecessary to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 13:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952170#M372147</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-11-29T13:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL, recode and convert variable from numeric to text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952181#M372154</link>
      <description>&lt;P&gt;Try using the RENAME= dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table tt2(drop=num_patientid) as
  select *
       , cat('patient ',num_patientid) as patientid
  from TEMP(rename=(patientid=num_patientid))
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But why are you using SQL for this?&amp;nbsp; It would be much clearer in normal SAS code instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tt2;
&amp;nbsp; set TEMP;
&amp;nbsp; char_patientid=cat('patient ',patientid);
&amp;nbsp; drop patientid;
&amp;nbsp; rename char_patientid=patientid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 16:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-recode-and-convert-variable-from-numeric-to-text/m-p/952181#M372154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-11-29T16:36:56Z</dc:date>
    </item>
  </channel>
</rss>

