<?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: Put Function not converting numeric values to character. in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432319#M13398</link>
    <description>&lt;P&gt;This would happen if VISIT2 is already defined as numeric.&amp;nbsp; Check the incoming data sets, and see if VISIT2 exists already.&amp;nbsp; If so, you can get of it easily enough.&amp;nbsp; For example, if it is part of PHRU_13AD1B:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set phru_13ad1b (drop=visit2) phru_13ad2b;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2018 16:30:51 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-01-30T16:30:51Z</dc:date>
    <item>
      <title>Put Function not converting numeric values to character.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432318#M13397</link>
      <description>&lt;P&gt;Hi SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a variable for patient visit that I want to convert from numeric to character. I've been using the put function to create a new variable and convert the values from the old numeric variable to character values. It works for some of my data sets, but for others it does not (same code and input variable is the same format in each data set). Maybe I'm just over looking a detail, but here is my issue below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I'm using SAS 9.4 TS1M4 on X64_7Pro platform.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable I have: "newvisit", format 11.&lt;/P&gt;&lt;P&gt;Variable I want: "visit2", format $10.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data phru_13ad (keep=studyid issue db sq visit2 variable dataset visitdate form); set phru_13ad1b phru_13ad2b;
	form="CRF13"; variable=" "; sq=" "; db=" "; visitdate=visitdate13; format visitdate date9.;
	dataset="phru_13add"; visit2=put(newvisit,10.);; run;

proc sort data=phru_13ad out=phru_13add nodupkey; by studyid visitdate visit2; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Log Reads:&lt;/P&gt;&lt;P&gt;110 data phru_13ad (keep=studyid issue db sq visit2 variable&lt;BR /&gt;110! dataset visitdate form); set phru_13ad1b phru_13ad2b;&lt;BR /&gt;111 form="CRF13"; variable=" "; sq=" "; db=" ";&lt;BR /&gt;111! visitdate=visitdate13; format visitdate date9.;&lt;BR /&gt;112 dataset="phru_13add"; visit2=put(newvisit,10.);; run;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric&lt;/P&gt;&lt;P&gt;values at the places given by: (Line):(Column).&lt;BR /&gt;112:34&lt;BR /&gt;NOTE: There were 1 observations read from the data set&lt;BR /&gt;WORK.PHRU_13AD1B.&lt;BR /&gt;NOTE: There were 1 observations read from the data set&lt;BR /&gt;WORK.PHRU_13AD2B.&lt;BR /&gt;NOTE: The data set WORK.PHRU_13AD has 2 observations and 9&lt;BR /&gt;variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason it's converting it back into a numeric format after it has been converted to character. Does anyone know why this is happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Cara&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432318#M13397</guid>
      <dc:creator>cbt2119</dc:creator>
      <dc:date>2018-01-30T16:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Put Function not converting numeric values to character.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432319#M13398</link>
      <description>&lt;P&gt;This would happen if VISIT2 is already defined as numeric.&amp;nbsp; Check the incoming data sets, and see if VISIT2 exists already.&amp;nbsp; If so, you can get of it easily enough.&amp;nbsp; For example, if it is part of PHRU_13AD1B:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set phru_13ad1b (drop=visit2) phru_13ad2b;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432319#M13398</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-30T16:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Put Function not converting numeric values to character.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432321#M13399</link>
      <description>&lt;P&gt;Does the variable already exist in those data sets? And if it does is the type character?&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/125665"&gt;@cbt2119&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi SAS Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a variable for patient visit that I want to convert from numeric to character. I've been using the put function to create a new variable and convert the values from the old numeric variable to character values. It works for some of my data sets, but for others it does not (same code and input variable is the same format in each data set). Maybe I'm just over looking a detail, but here is my issue below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I'm using SAS 9.4 TS1M4 on X64_7Pro platform.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable I have: "newvisit", format 11.&lt;/P&gt;
&lt;P&gt;Variable I want: "visit2", format $10.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data phru_13ad (keep=studyid issue db sq visit2 variable dataset visitdate form); set phru_13ad1b phru_13ad2b;
	form="CRF13"; variable=" "; sq=" "; db=" "; visitdate=visitdate13; format visitdate date9.;
	dataset="phru_13add"; visit2=put(newvisit,10.);; run;

proc sort data=phru_13ad out=phru_13add nodupkey; by studyid visitdate visit2; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log Reads:&lt;/P&gt;
&lt;P&gt;110 data phru_13ad (keep=studyid issue db sq visit2 variable&lt;BR /&gt;110! dataset visitdate form); set phru_13ad1b phru_13ad2b;&lt;BR /&gt;111 form="CRF13"; variable=" "; sq=" "; db=" ";&lt;BR /&gt;111! visitdate=visitdate13; format visitdate date9.;&lt;BR /&gt;112 dataset="phru_13add"; visit2=put(newvisit,10.);; run;&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric&lt;/P&gt;
&lt;P&gt;values at the places given by: (Line):(Column).&lt;BR /&gt;112:34&lt;BR /&gt;NOTE: There were 1 observations read from the data set&lt;BR /&gt;WORK.PHRU_13AD1B.&lt;BR /&gt;NOTE: There were 1 observations read from the data set&lt;BR /&gt;WORK.PHRU_13AD2B.&lt;BR /&gt;NOTE: The data set WORK.PHRU_13AD has 2 observations and 9&lt;BR /&gt;variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some reason it's converting it back into a numeric format after it has been converted to character. Does anyone know why this is happening?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Cara&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432321#M13399</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-30T16:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Put Function not converting numeric values to character.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432324#M13400</link>
      <description>&lt;P&gt;Hi and thank you - this worked!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432324#M13400</guid>
      <dc:creator>cbt2119</dc:creator>
      <dc:date>2018-01-30T16:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Put Function not converting numeric values to character.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432327#M13401</link>
      <description>&lt;P&gt;I think you will find that your variable NEWVISIT is already character if you run proc contents or examine the data set columns for data set phru_13ad1b&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;This note from your log&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric

values at the places given by: (Line):(Column).
112:34
&lt;/PRE&gt;
&lt;P&gt;says that something that is already character was treated in a numeric fashion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;112 dataset="phru_13add"; visit2=put(newvisit,10.);; run;&lt;/P&gt;
&lt;P&gt;Look in your original code at column 34 for the above line. Likely PUT is at position 34. Which tells you what attempted to treat a character variable as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will get different behaviors if your variables come from data sets created by proc import as each time import runs it makes a guess as to the contents of the file. So sometimes a variable will be character and sometimes not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW it is much easier to read and understand code if each line is a single statement.&lt;/P&gt;
&lt;PRE&gt;data phru_13ad (keep=studyid issue db sq visit2 variable dataset visitdate form); 
   set phru_13ad1b phru_13ad2b;
   form="CRF13"; 
   variable=" "; 
   sq=" "; 
   db=" "; 
   visitdate=visitdate13; 
   format visitdate date9.;
   dataset="phru_13add"; 
   visit2=put(newvisit,10.);
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Put-Function-not-converting-numeric-values-to-character/m-p/432327#M13401</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-30T16:37:36Z</dc:date>
    </item>
  </channel>
</rss>

