<?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: SAS update table format in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814081#M20331</link>
    <description>&lt;P&gt;If you want to convert a number into text you need decide how your want it formatted.&lt;/P&gt;
&lt;P&gt;One way is to just use whatever format the variable already had assigned to.&amp;nbsp; This is really easy with VVALUE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  new_text = vvalue(text);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 18 May 2022 14:42:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-05-18T14:42:52Z</dc:date>
    <item>
      <title>SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814049#M20324</link>
      <description>&lt;P&gt;Hi there I have the following dataset where the column name is called Text and the datatype of this column is numeric. How do I convert any column that has the name Text to a Character datatype?&lt;/P&gt;
&lt;P&gt;Initial dataset:&lt;/P&gt;
&lt;TABLE width="229"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="101"&gt;Age&lt;/TD&gt;
&lt;TD width="64"&gt;Gender&lt;/TD&gt;
&lt;TD width="64"&gt;Text&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;F&lt;/TD&gt;
&lt;TD&gt;45&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;M&lt;/TD&gt;
&lt;TD&gt;63&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;M&lt;/TD&gt;
&lt;TD&gt;88&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;M&lt;/TD&gt;
&lt;TD&gt;90&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;I have use the below to identify the datatypes of the columns and I store this data in a table called myd&lt;/P&gt;
&lt;PRE&gt;proc iml;
tClass = TableCreateFromDataSet("Work", "mycsv");
colnames = TableGetVarName(tClass);
type = TableGetVarType(tClass);
isNum = TableIsVarNumeric(tClass);
print (type // char(isNum))[c=colnames r={"Type" "IsNum"}];
create myd var {colnames type};
append;
close myd;&lt;/PRE&gt;
&lt;P&gt;Then I perform a check:&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table test as 
select * ,
case when colnames like 'Text%' and Type &amp;lt;&amp;gt; 'C' then  'C'
else Type
end as NewType
from myd
;quit;&lt;/PRE&gt;
&lt;P&gt;result:&lt;/P&gt;
&lt;TABLE width="229"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="101"&gt;COLNAMES&lt;/TD&gt;
&lt;TD width="64"&gt;TYPE&lt;/TD&gt;
&lt;TD width="64"&gt;NewType&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;String&lt;/TD&gt;
&lt;TD&gt;N&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Now that I can see the types and am able to identify which columns need an update, I am not sure how to instruct my initial dataset to convert my column called Text from an numeric to Character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 12:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814049#M20324</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-05-18T12:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814058#M20326</link>
      <description>&lt;P&gt;I would first ask why a data set that you want a variable to be numeric was created as text. If you make sure that doesn't happen then you prevent problems instead of having to continuously fix them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An extremely high percentage of data type problems like this arise from not controlling how data is brought into SAS. How did you read that data into a SAS data set in the first place? It may be easier to reread the data than to "fix" it afterward.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 13:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814058#M20326</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-18T13:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814061#M20327</link>
      <description>hi, it can not be controlled as the are thousands of csv files loaded by various parties</description>
      <pubDate>Wed, 18 May 2022 13:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814061#M20327</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-05-18T13:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814077#M20328</link>
      <description>&lt;P&gt;Do you expect to report minimums, maximums, averages, variances, etc. of these numeric values masquerading as text?&amp;nbsp; Not even min or max in this list of stats can be reliably produced from numeric character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is future analysis to be done, then make the variable into a type that represents ongoing usage rather that the vagueries of what appears to be "crowd-sourced" data.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 14:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814077#M20328</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-18T14:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814078#M20329</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;hi, it can not be controlled as the are thousands of csv files loaded by various parties&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you explain more what the issue is?&lt;/P&gt;
&lt;P&gt;It is very easy to control how variables are defined when reading a CSV file.&amp;nbsp; Those are just simple delimited text files, so just write a data step to read the file and you have full control over the names and types of the variables.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 14:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814078#M20329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-18T14:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814081#M20331</link>
      <description>&lt;P&gt;If you want to convert a number into text you need decide how your want it formatted.&lt;/P&gt;
&lt;P&gt;One way is to just use whatever format the variable already had assigned to.&amp;nbsp; This is really easy with VVALUE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  new_text = vvalue(text);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2022 14:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814081#M20331</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-18T14:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814097#M20332</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;hi, it can not be controlled as the are thousands of csv files loaded by various parties&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It has nothing to do with who uploaded them, it is the process used to READ the CSV files. That is controlled by you or the recipients.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show the code you are using to read ONE of these files. At least.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 15:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814097#M20332</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-18T15:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814202#M20333</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 01:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814202#M20333</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-19T01:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814211#M20334</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;hi, it can not be controlled as the are thousands of csv files loaded by various parties&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No issue at all. CSV files are read with DATA steps, where you have&amp;nbsp;&lt;EM&gt;full control&lt;/EM&gt;&amp;nbsp;over how data is read.&lt;/P&gt;
&lt;P&gt;Do not use PROC IMPORT, particularly not when you need consistency.&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 06:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814211#M20334</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-19T06:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814219#M20335</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is not a IML issue. The code here is only a very complicated replacement for a simple query against DICTIONARY.COLUMNS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
  select
    name,
    type,
    case 
      when name like 'Text%' and Type &amp;lt;&amp;gt; 'C' then  'C'
      else Type
    end as Newtype
  from dictionary.columns
  where libname = "WORK" and memname = "MYCSV"
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 06:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/814219#M20335</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-19T06:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS update table format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/850583#M20650</link>
      <description>The General Process for Software Updates&lt;BR /&gt;Step 1: Learn about the Availability of a New Release.&lt;BR /&gt;Step 2: Run the SAS System Evaluation Tool.&lt;BR /&gt;Step 3: Run a Deployment Registry Report.&lt;BR /&gt;Step 4: Assess the Impact of Upgrading the Software at Your Site.&lt;BR /&gt;Step 5: Request a New Product Release or Maintenance Release.&lt;BR /&gt;Regards,&lt;BR /&gt;Rachel Gomez</description>
      <pubDate>Wed, 21 Dec 2022 07:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-update-table-format/m-p/850583#M20650</guid>
      <dc:creator>RacheLGomez123</dc:creator>
      <dc:date>2022-12-21T07:46:53Z</dc:date>
    </item>
  </channel>
</rss>

