<?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: finding an Age with 3 different variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806955#M33593</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347594"&gt;@Cooksam13&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;51531&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;WashBD&lt;/TD&gt;
&lt;TD&gt;Num&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;YEAR.&lt;/TD&gt;
&lt;TD&gt;BEST32.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;TestD&lt;/TD&gt;
&lt;TD&gt;Num&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;YEAR.&lt;/TD&gt;
&lt;TD&gt;YYMMDD10.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;BD&lt;/TD&gt;
&lt;TD&gt;Char&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;$EAR.&lt;/TD&gt;
&lt;TD&gt;$10.&lt;/TD&gt;
&lt;TD&gt;BD&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;so this is what it is coming up as and I am having trouble converting BD to a date&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;WASHBD is a numeric variable that is being displayed using the YEAR format and has 32. informat attached to it. (BEST is the name of a FORMAT if you use it as in INFORMAT then it is treated as an alias for the normal numeric informat).&lt;/P&gt;
&lt;P&gt;TESTD is a numeric variable that is being displayed using the YEAR format and has the YYMMDD10. informat attached to it.&lt;/P&gt;
&lt;P&gt;BD is a character variable that can hold up to 10 bytes.&amp;nbsp; Someone tried to attach the numeric format YEAR to it and that is getting displayed by PROC CONTENTS as $EAR because all character formats should start with a $.&amp;nbsp; It also has the $10. informat attached to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to convert BD into a DATE value use the INPUT() function with an appropriate informat.&amp;nbsp; But you will need to store the results into a numeric variable and BD is already being used as the name of a character variable.&amp;nbsp; So if it has strings like '23-12-2020' then you want to use the DDMMYY informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;bd_date = input(bd,ddmmyy10.);
format bd_date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure what kind of values WASHBD has.&amp;nbsp; You should print it using different formats and see what the values look like.&amp;nbsp; If they are date values for people's birthdays then they should be integer values from about -21,000 to about 23,000.&lt;/P&gt;
&lt;PRE&gt;461   data _null_;
462     start=intnx('year',today(),-120,'b');
463     end=today();
464     put start= :comma10. start yymmdd10.;
465     put end= :comma10. +2 end yymmdd10.;
466   run;

start=-21,184 1902-01-01
end=22,744   2022-04-09
&lt;/PRE&gt;
&lt;P&gt;If they are YEAR values then they should be integers between 1900 and 2021. In which case WASHBD should NOT have the YEAR format attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly for TESTD, but since it has an informat that is appropriate for a date value attached to it then it is more likely that it has actual date values in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Apr 2022 22:22:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-09T22:22:30Z</dc:date>
    <item>
      <title>finding an Age with 3 different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806868#M33589</link>
      <description>&lt;P&gt;Hi I am trying to compare 2 explanatory variables and the age of receiving a test.&amp;nbsp;&lt;/P&gt;&lt;P&gt;one set (Alaska) would have received the test at their birth and is put into a column called "BD"&lt;/P&gt;&lt;P&gt;the other set (Washington) may have received the test at birth or later in life, I have their birthdate (WashBD) and the date they received the test (TestD)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;overall I want to make a new variable describing their age that all sets received the test&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the dates are also a bit of a mess and are categorized differently&amp;nbsp;&lt;/P&gt;&lt;P&gt;BD = YYYY/MM/DD&lt;/P&gt;&lt;P&gt;WashBD = YYYY&lt;/P&gt;&lt;P&gt;TestD = DD-MM-YYYY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can someone help?&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 22:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806868#M33589</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-08T22:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: finding an Age with 3 different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806894#M33590</link>
      <description>&lt;P&gt;this is the code I am working with&amp;nbsp;&lt;/P&gt;&lt;P&gt;the first data step i get what i want which is just the year showing up but when I do the second data step it shows warnings and reverts the dates in the HBT to SAS inputs for dates and shows this error "&lt;SPAN&gt;Invalid numeric data, BD='2010/02/11' , at line 73 column 41" in multiple areas&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;	data want;&lt;BR /&gt;	set have;&lt;BR /&gt;	Format WashBD TestD BD Year.;&lt;BR /&gt;	run;&lt;BR /&gt; &lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set want;&lt;BR /&gt;&lt;BR /&gt;    if not missing(WashBD) then DOB = WashBD;&lt;BR /&gt;    if not missing(BD) then DOB = BD;&lt;BR /&gt;    if not missing(BD) then HBT = BD;&lt;BR /&gt;    if not missing(TestD) then HBT = TestD;&lt;BR /&gt;Format WashBD TestD BD Year.;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 02:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806894#M33590</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-09T02:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: finding an Age with 3 different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806898#M33591</link>
      <description>&lt;P&gt;&lt;SPAN&gt;error "&lt;/SPAN&gt;&lt;SPAN&gt;Invalid numeric data, BD='2010/02/11' indicates that your variable BD is of type character and not numeric. If true then already in your first data step &lt;EM&gt;format bd year.;&lt;/EM&gt; shouldn't work and you should get an error similar to below.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1649475150202.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70265i0275B420545A8632/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1649475150202.png" alt="Patrick_0-1649475150202.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Ideally you provide representative sample data created via a fully tested SAS data step that you post here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you already could do: Run below code and share with use the result. This will show us the data types and formats of your source variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=work.have;
run;quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Apr 2022 03:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806898#M33591</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-04-09T03:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: finding an Age with 3 different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806943#M33592</link>
      <description>&lt;P&gt;&amp;nbsp;51531&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;WashBD&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;YEAR.&lt;/TD&gt;&lt;TD&gt;BEST32.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TestD&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;YEAR.&lt;/TD&gt;&lt;TD&gt;YYMMDD10.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;BD&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;$EAR.&lt;/TD&gt;&lt;TD&gt;$10.&lt;/TD&gt;&lt;TD&gt;BD&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;so this is what it is coming up as and I am having trouble converting BD to a date&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 18:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806943#M33592</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-09T18:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: finding an Age with 3 different variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806955#M33593</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347594"&gt;@Cooksam13&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;51531&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;WashBD&lt;/TD&gt;
&lt;TD&gt;Num&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;YEAR.&lt;/TD&gt;
&lt;TD&gt;BEST32.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;TestD&lt;/TD&gt;
&lt;TD&gt;Num&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;YEAR.&lt;/TD&gt;
&lt;TD&gt;YYMMDD10.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;BD&lt;/TD&gt;
&lt;TD&gt;Char&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;$EAR.&lt;/TD&gt;
&lt;TD&gt;$10.&lt;/TD&gt;
&lt;TD&gt;BD&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;so this is what it is coming up as and I am having trouble converting BD to a date&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;WASHBD is a numeric variable that is being displayed using the YEAR format and has 32. informat attached to it. (BEST is the name of a FORMAT if you use it as in INFORMAT then it is treated as an alias for the normal numeric informat).&lt;/P&gt;
&lt;P&gt;TESTD is a numeric variable that is being displayed using the YEAR format and has the YYMMDD10. informat attached to it.&lt;/P&gt;
&lt;P&gt;BD is a character variable that can hold up to 10 bytes.&amp;nbsp; Someone tried to attach the numeric format YEAR to it and that is getting displayed by PROC CONTENTS as $EAR because all character formats should start with a $.&amp;nbsp; It also has the $10. informat attached to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to convert BD into a DATE value use the INPUT() function with an appropriate informat.&amp;nbsp; But you will need to store the results into a numeric variable and BD is already being used as the name of a character variable.&amp;nbsp; So if it has strings like '23-12-2020' then you want to use the DDMMYY informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;bd_date = input(bd,ddmmyy10.);
format bd_date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure what kind of values WASHBD has.&amp;nbsp; You should print it using different formats and see what the values look like.&amp;nbsp; If they are date values for people's birthdays then they should be integer values from about -21,000 to about 23,000.&lt;/P&gt;
&lt;PRE&gt;461   data _null_;
462     start=intnx('year',today(),-120,'b');
463     end=today();
464     put start= :comma10. start yymmdd10.;
465     put end= :comma10. +2 end yymmdd10.;
466   run;

start=-21,184 1902-01-01
end=22,744   2022-04-09
&lt;/PRE&gt;
&lt;P&gt;If they are YEAR values then they should be integers between 1900 and 2021. In which case WASHBD should NOT have the YEAR format attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly for TESTD, but since it has an informat that is appropriate for a date value attached to it then it is more likely that it has actual date values in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 22:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-an-Age-with-3-different-variables/m-p/806955#M33593</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-09T22:22:30Z</dc:date>
    </item>
  </channel>
</rss>

