<?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: Command for populating a character variable as numeric in output files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275709#M55166</link>
    <description>&lt;P&gt;As an aside it looks like you have a date and a time variable that are character. You may want to consider using an appropriate date or time informat and assigning date and time formats to those variables. If you ever want to do to things like calculating subject age or intervals between visits for the same subject then SAS date and time variables will make it a lot easier with the various functins designed to work with those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And by any chance is that VISIT variable actually a date also? When I saw your example my first thought was 1999, January 1. If so let us know which of the bits is month and day of month.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2016 15:27:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-06-07T15:27:02Z</dc:date>
    <item>
      <title>Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275574#M55112</link>
      <description>&lt;P&gt;Hi Guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a command used to populate a variable as numeric in datasets. The visit number variable for a visit 99.1.01 is considered as character variable in SAS program since it has 2 decimal values. I need to populate this value (99.1.01) as a numeric value. Kindly suggest me how to move forward with it. There are totally 8 other variables which are working fine. Only the VISIT variable has issue. I have pasted the program below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data datadir.ABCD;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;label STUDY = 'Study Code'&lt;BR /&gt;SUBJECT = 'Enrolment Code'&lt;BR /&gt;&lt;STRONG&gt;VISIT = 'Visit Number'&lt;/STRONG&gt;&lt;BR /&gt;SPECDAT = 'Date of Collection'&lt;BR /&gt;SPECTIM = 'Time of Collection'&lt;BR /&gt;SPECID = 'Specimen ID'&lt;BR /&gt;PROTSCHD = 'Protocol Schedule'&lt;BR /&gt;COMMENTS = 'Specimen Comments';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;length STUDY $11.&lt;BR /&gt;SUBJECT $8.&lt;BR /&gt;&lt;STRONG&gt;VISIT 8&lt;/STRONG&gt;.&lt;BR /&gt;SPECDAT $10.&lt;BR /&gt;SPECTIM $5.&lt;BR /&gt;SPECID $20.&lt;BR /&gt;PROTSCHD $20.&lt;BR /&gt;COMMENTS $200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;infile datafile delimiter = '|' dsd missover lrecl=2000;&lt;/P&gt;&lt;P&gt;input STUDY SUBJECT &lt;STRONG&gt;VISIT&lt;/STRONG&gt; SPECDAT SPECTIM SPECID PROTSCHD COMMENTS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks,&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 06:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275574#M55112</guid>
      <dc:creator>dhaha001</dc:creator>
      <dc:date>2016-06-07T06:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275580#M55113</link>
      <description>&lt;P&gt;99.1.01 can never be a numeric value. Numeric values can only have one decimal point, period. That's basic calculus.&lt;/P&gt;
&lt;P&gt;So you need to make a decision&lt;/P&gt;
&lt;P&gt;Is it&lt;/P&gt;
&lt;P&gt;991.01&lt;/P&gt;
&lt;P&gt;99.101&lt;/P&gt;
&lt;P&gt;99101&lt;/P&gt;
&lt;P&gt;990101&lt;/P&gt;
&lt;P&gt;99001001&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 06:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275580#M55113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T06:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275588#M55117</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74000"&gt;@dhaha001﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also consider storing the three components of your visit numbers (e.g. 99, 1 and 01) in three separate (possibly numeric) variables. This would facilitate grouping and selection of observations based on these variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should definitely avoid numeric visit numbers like 991.01, i.e. (mis)using the decimal point as a mere separator between two ordinal values. (Reason: risk of numeric representation issues.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option would be to create a format that assigns labels like "99.1.01" to numeric visit numbers (still to be defined) such as 1, 2, 3, ...&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 08:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275588#M55117</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-07T08:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275593#M55119</link>
      <description>&lt;P&gt;I agree with both&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&amp;nbsp;on both their comments other than format, as whilst you could force it using a format, I don't believe that is good working practice and would just be confusing. &amp;nbsp;Also be aware that that "visit" number is not valid per standard data models - SDMT/ADaM. &amp;nbsp;There are plenty of different ways of setting up visit numbering, for instance visit + repeat number + timepoint. &amp;nbsp;I would suggest from your example that 99 indicates an unscheduled visit, 1 being the first repeat, and 01 being the timepoint thus:&lt;/P&gt;
&lt;P&gt;AVISITN &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ATPTN&lt;/P&gt;
&lt;P&gt;99.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were using ADaM.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 08:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275593#M55119</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-07T08:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275600#M55122</link>
      <description>Dear KurtBremser,&lt;BR /&gt;Thanks for your quick feedback. I was checking if we can populate the&lt;BR /&gt;character value (99.1.01) as a numeric value in data file.&lt;BR /&gt;That is, any command which could be use to get the desired output.&lt;BR /&gt;Regards,&lt;BR /&gt;Harsha&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 07 Jun 2016 09:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275600#M55122</guid>
      <dc:creator>dhaha001</dc:creator>
      <dc:date>2016-06-07T09:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275602#M55123</link>
      <description>&lt;P&gt;You must supply the "desired output", then we can help you with code that creates that output.&lt;/P&gt;
&lt;P&gt;Let me repeat:&lt;/P&gt;
&lt;P&gt;99.1.01 is NOT a number, therefore you can't store it in a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can, for instance, split it into several numeric variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
num1 = input(scan(charval,1,'.'),2.);
num2 = input(scan(charval,2,'.'),2.);
num3 = input(scan(charval,3,'.'),2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jun 2016 09:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275602#M55123</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T09:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275709#M55166</link>
      <description>&lt;P&gt;As an aside it looks like you have a date and a time variable that are character. You may want to consider using an appropriate date or time informat and assigning date and time formats to those variables. If you ever want to do to things like calculating subject age or intervals between visits for the same subject then SAS date and time variables will make it a lot easier with the various functins designed to work with those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And by any chance is that VISIT variable actually a date also? When I saw your example my first thought was 1999, January 1. If so let us know which of the bits is month and day of month.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 15:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/275709#M55166</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-07T15:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Command for populating a character variable as numeric in output files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/276769#M55490</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for all your support. I checked with few of my collegues and SAS tech team and found out that we cannot provide a SAS output as a numeric for values with two periods (99.1.01). I have initiated a programming request in our database by changing logic of this kind of outputs. 99.101.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 15:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Command-for-populating-a-character-variable-as-numeric-in-output/m-p/276769#M55490</guid>
      <dc:creator>dhaha001</dc:creator>
      <dc:date>2016-06-12T15:00:02Z</dc:date>
    </item>
  </channel>
</rss>

