<?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: using multiple function  strip(put(input(compress in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858494#M339203</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Thank you for your response and solution. code is working...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DOD variable is numeric which contents only dates.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Feb 2023 11:14:19 GMT</pubDate>
    <dc:creator>shyamtawde</dc:creator>
    <dc:date>2023-02-13T11:14:19Z</dc:date>
    <item>
      <title>using multiple function  strip(put(input(compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858487#M339198</link>
      <description>&lt;P&gt;if first.subject then do;&lt;BR /&gt;if dod ne . then enddt=strip(put(input(compress(dod,"-"),??date7.),??date9.));&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;showing below in log and enddt not populating.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;321 data ex(drop=dod adt siteid);&lt;BR /&gt;322 set ex_srt;&lt;BR /&gt;323 /* format startdt enddt date9. starttm endtm time8.;*/&lt;BR /&gt;324 retain startdt starttm rfstdt enddt endtm rfendt;&lt;BR /&gt;325 by studyno subject dod;&lt;BR /&gt;326 if first.subject then do;&lt;BR /&gt;327 if dod ne . then enddt=strip(put(input(compress(dod,"-"),??date7.),??date9.));&lt;BR /&gt;328 if adt ne . then endtm=strip(adt);&lt;BR /&gt;329 /* if length(strip(endtm)) le 7 and index(endtm,":") eq 2 then&lt;BR /&gt;329! endtm="0"||strip(endtm); */&lt;BR /&gt;330 %dateder( indate=enddt, intime=endtm, outdt=rfendt);&lt;BR /&gt;331 /*rfstdt=input(strip(startdt||":"||starttm),??datetime20.);*/&lt;BR /&gt;332 end;&lt;BR /&gt;333&lt;BR /&gt;334 if last.subject then do;&lt;BR /&gt;335 if dod ne . then startdt=strip(put(input(compress(dod,"-"),??date7.),??date9.));&lt;BR /&gt;336 if adt ne . then starttm=strip(adt);&lt;BR /&gt;337 /* if length(strip(starttm)) le 7 and index(starttm,":") eq 2 then&lt;BR /&gt;337! starttm="0"||strip(starttm); */&lt;BR /&gt;338 %dateder( indate=startdt, intime=starttm, outdt=rfstdt);&lt;BR /&gt;339 /* rfendt=input(strip(enddt||":"||endtm),??datetime20.);*/&lt;BR /&gt;340 output;&lt;BR /&gt;341 end;&lt;BR /&gt;342 run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;327:55 328:36 335:57 336:38&lt;BR /&gt;WARNING: The variable siteid in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;NOTE: There were 112 observations read from the data set WORK.EX_SRT.&lt;BR /&gt;NOTE: The data set WORK.EX has 56 observations and 8 variables.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 09:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858487#M339198</guid>
      <dc:creator>shyamtawde</dc:creator>
      <dc:date>2023-02-13T09:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple function  strip(put(input(compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858492#M339201</link>
      <description>&lt;P&gt;The problem seems to be that the DOD variable is numeric, and the COMPRESS function converts it to character. If it is numeric, it probably has a date or datetime format. But the COMPRESS function will not use that format, but a default format (I assume BEST32.) to convert it, and that will not give usable result when you try to read it with the INPUT function and informat DATE7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should probably change the code to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if dod ne . then enddt=put(dod,date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if DOD is a date, and to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if dod ne . then enddt=put(datepart(dod),date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if it is a datetime variable.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 10:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858492#M339201</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-02-13T10:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple function  strip(put(input(compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858494#M339203</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for your response and solution. code is working...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DOD variable is numeric which contents only dates.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 11:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858494#M339203</guid>
      <dc:creator>shyamtawde</dc:creator>
      <dc:date>2023-02-13T11:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple function  strip(put(input(compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858495#M339204</link>
      <description>&lt;P&gt;Maxim 3: &lt;STRONG&gt;Know Your Data&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Know the type and (if assigned) display format of variables dod and adt. I guess they are already numeric, with a date/time format assigned, so the whole conversion process serves no purpose.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 11:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858495#M339204</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-13T11:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: using multiple function  strip(put(input(compress</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858496#M339205</link>
      <description>&lt;P&gt;So you want to get the start and end datetimes of a process?&lt;/P&gt;
&lt;P&gt;One easy step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table ex as
  select
    studyno,
    subject,
    min(dhms(dod,0,0,adt)) as start_datetime format=e8601dt19.,
    max(dhms(dod,0,0,adt) as end_datetime format=e8601dt19.
  from ex_srt
  group by studyno, subject
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This step will sort the input table internally, so you can omit any preceding sort.&lt;/P&gt;
&lt;P&gt;If your dates and times were already in a combined variable, you could use PROC SUMMARY:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=ex_srt nway;
class studyno subject;
var datetime;
output out=ex (drop=_TYPE_ _FREQ_) min(datetime)=start_datetime max(datetime)=end_datetime;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Feb 2023 11:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-multiple-function-strip-put-input-compress/m-p/858496#M339205</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-13T11:33:22Z</dc:date>
    </item>
  </channel>
</rss>

