[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Deriving a variable with increasing values chronologically
From:       Stanford Mwasongwe <smwasongwe () GMAIL ! COM>
Date:       2021-10-12 14:48:05
Message-ID: CAAfzsF4QNb-KH+inf9vwZ1TpPKj3u089iCmcjnMpqahmK6M4jA () mail ! gmail ! com
[Download RAW message or body]

Hey Nat,
This one works! Thanks for help once again, I was pulled to do other things
but finally I was able to get back to this and finish with your suggestions.

Best
*Stanford*



On Thu, Oct 7, 2021 at 1:56 PM Nat Wooding <nathani@verizon.net> wrote:

> Stanford
>
> Try something like this;
>
> Nat
>
> data have;
> infile cards missover;
>
> input id $1. num ;
> cards;
> 1  1
> 2  2
> 3
> 4
> 5
> 6   6
> 7
> 8   8
> ;
> data want;
> set have;
> retain hold;
> if num then hold = num;
> else do;
> num = hold + 1;
> hold = num;
> end;
> run;
>
>
>
>
> On Thursday, October 7, 2021, 02:45:00 PM EDT, Stanford Mwasongwe <
> smwasongwe@gmail.com> wrote:
>
>
> Thanks everyone, I should have added more info into this, the variable
> AccessionNumber already exists but there are several records with missing
> AccessionNumber. For those with missing accessionNumber i am looking to
> give them a value YYYYMMDD0001 in an increasing order. I will work with
> these suggestions here trying to a do loop.
> Thanks again!
>
> *Stanford*
>
>
>
> On Wed, Oct 6, 2021 at 5:29 PM Retired Mainframer <
> 00000fdaa76f2a18-dmarc-request@listserv.uga.edu> wrote:
>
> If the new variable is numeric, prime the pump by retaining this variable
> set to input(put(today(),yymmddn8.),8.)*10000.  Then for each record,
> simply add 1.
>
>
>
> If the variable is character, retain a counter CTR set to zero and a
> character variable NOW set to put(today(),yymmddn8.).  Then for each
> record, increment the counter and set the character variable to
> cat(NOW,put(CTR,z4.).
>
>
>
> *From:* SAS(r) Discussion <SAS-L@LISTSERV.UGA.EDU> *On Behalf Of *Stanford
> Mwasongwe
> *Sent:* Wednesday, October 6, 2021 2:07 PM
> *To:* SAS-L@LISTSERV.UGA.EDU
> *Subject:* Deriving a variable with increasing values chronologically
>
>
>
> Hi list,
>
> I need to create a variable, accessionnumber with with values 20211006
> followed by '0001' for the first record and increasing chronologically,
> 202110060001, 202110060002 etc, I am not really sure how to approach this
> problem, any idea will be of great help.
>
>
>
> Thanks
>
>
>
> *Stanford*
>
>
>
>

[Attachment #3 (text/html)]

<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Hey \
Nat,</div><div class="gmail_default" style="font-family:verdana,sans-serif">This one \
works! Thanks for help once again, I was pulled to do other things but finally I was \
able to get back to this and finish with your suggestions.</div><div \
class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div \
class="gmail_default" style="font-family:verdana,sans-serif">Best  </div><div><div \
dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div \
dir="ltr"><div><span style="font-size:x-small"><font size="2"><font><span \
style="font-size:10pt"><font face="bookman old style, new york, times, serif" \
color="#444444"><b>Stanford</b></font></span></font></font></span></div><div><br></div></div></div></div><br></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 7, 2021 at 1:56 PM \
Nat Wooding &lt;<a href="mailto:nathani@verizon.net">nathani@verizon.net</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div \
style="font-family:&quot;Helvetica \
Neue&quot;,Helvetica,Arial,sans-serif;font-size:13px"><div></div>  <div \
dir="ltr">Stanford</div><div dir="ltr"><br></div><div dir="ltr">Try something like \
this;</div><div dir="ltr"><br></div><div dir="ltr">Nat</div><div \
dir="ltr"><br></div><div dir="ltr"><div><div>data have;</div><div>infile cards \
missover;</div><div><br></div><div>input id $1. num ;</div><div>cards;</div><div>1   \
1</div><div>2   2</div><div>3    </div><div>4</div><div>5</div><div>6     \
6</div><div>7</div><div>8     8</div><div>;</div><div>data want;</div><div>set \
have;</div><div>retain hold;</div><div>if num then hold = num;</div><div>else \
do;</div><div>num = hold + 1;</div><div>hold = \
num;</div><div>end;</div><div>run;</div></div><br></div><div dir="ltr"><br></div><div \
dir="ltr"><br></div><div><br></div>  
        </div><div id="gmail-m_-8723933307630110413ydp8a940626yahoo_quoted_3659501868">
                
            <div style="font-family:&quot;Helvetica \
Neue&quot;,Helvetica,Arial,sans-serif;font-size:13px;color:rgb(38,40,42)">  
                <div>
                    On Thursday, October 7, 2021, 02:45:00 PM EDT, Stanford Mwasongwe \
&lt;<a href="mailto:smwasongwe@gmail.com" \
target="_blank">smwasongwe@gmail.com</a>&gt; wrote:  </div>
                <div><br></div>
                <div><br></div>
                <div><div \
id="gmail-m_-8723933307630110413ydp8a940626yiv2853498325"><div><div dir="ltr"><div \
style="font-family:verdana,sans-serif">Thanks everyone, I should have added more info \
into this, the variable AccessionNumber already exists but there are several records \
with missing AccessionNumber. For those with missing accessionNumber i am looking to \
give them a value YYYYMMDD0001 in an increasing order. I will work with these \
suggestions here trying to a do loop.</div><div \
style="font-family:verdana,sans-serif">Thanks again!</div><div \
style="font-family:verdana,sans-serif"><br clear="none"></div><div><div \
dir="ltr"><div dir="ltr"><div><span style="font-size:x-small"><font size="2" \
style="background-color:inherit"><font><span style="font-size:10pt"><font \
face="bookman old style, new york, times, serif" color="#444444" \
style="background-color:inherit"><b>Stanford</b></font></span></font></font></span></div><div><br \
clear="none"></div></div></div></div><br clear="none"></div><br clear="none"><div \
id="gmail-m_-8723933307630110413ydp8a940626yiv2853498325yqt59012"><div><div \
dir="ltr">On Wed, Oct 6, 2021 at 5:29 PM Retired Mainframer &lt;<a shape="rect" \
href="mailto:00000fdaa76f2a18-dmarc-request@listserv.uga.edu" rel="nofollow" \
target="_blank">00000fdaa76f2a18-dmarc-request@listserv.uga.edu</a>&gt; wrote:<br \
clear="none"></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div><p><font size="3" \
face="Times New Roman"><span style="font-size:12pt;font-family:&quot;New \
serif&quot;">If the new variable is numeric, prime the pump by retaining this \
variable set to input(put(today(),yymmddn8.),8.)*10000.<span>   </span>Then for each \
record, simply add 1.<u></u><u></u></span></font></p><p><font size="3" face="Times \
New Roman"><span style="font-size:12pt;font-family:&quot;New serif&quot;"><u></u>  \
<u></u></span></font></p><p><font size="3" face="Times New Roman"><span \
style="font-size:12pt;font-family:&quot;New serif&quot;">If the variable is \
character, retain a counter CTR set to zero and a character variable NOW set to \
put(today(),yymmddn8.).<span>   </span>Then for each record, increment the counter \
and set the character variable to \
cat(NOW,put(CTR,z4.).<u></u><u></u></span></font></p><p><font size="3" face="Times \
New Roman"><span style="font-size:12pt;font-family:&quot;New serif&quot;"><u></u>  \
<u></u></span></font></p><div \
style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid \
rgb(225,225,225);padding:3pt 0in 0in"><p><b><font size="2" face="Calibri"><span \
style="font-size:11pt;font-weight:bold">From:</span></font></b><span> SAS(r) \
Discussion &lt;<a shape="rect" href="mailto:SAS-L@LISTSERV.UGA.EDU" rel="nofollow" \
target="_blank">SAS-L@LISTSERV.UGA.EDU</a>&gt; <b><span style="font-weight:bold">On \
Behalf Of </span></b>Stanford Mwasongwe<br clear="none"><b><span \
style="font-weight:bold">Sent:</span></b> Wednesday, October 6, 2021 2:07 PM<br \
clear="none"><b><span style="font-weight:bold">To:</span></b> <a shape="rect" \
href="mailto:SAS-L@LISTSERV.UGA.EDU" rel="nofollow" \
target="_blank">SAS-L@LISTSERV.UGA.EDU</a><br clear="none"><b><span \
style="font-weight:bold">Subject:</span></b> Deriving a variable with increasing \
values chronologically<u></u><u></u></span></p></div><p><font size="2" \
face="Calibri"><span style="font-size:11pt"><u></u>  \
<u></u></span></font></p><div><div><div><div><p><font size="2" face="Verdana"><span \
style="font-size:11pt;font-family:Verdana,sans-serif">Hi \
list,<u></u><u></u></span></font></p></div><div><p><font size="2" \
face="Verdana"><span style="font-size:11pt;font-family:Verdana,sans-serif">I need to \
create a variable, accessionnumber with with values 20211006 followed by \
&#39;0001&#39; for the first record and increasing chronologically, 202110060001, \
202110060002 etc, I am not really sure how to approach this problem, any idea will be \
of great help.<u></u><u></u></span></font></p></div><div><p><font size="2" \
face="Verdana"><span style="font-size:11pt;font-family:Verdana,sans-serif"><u></u>  \
<u></u></span></font></p></div><div><p><font size="2" face="Verdana"><span \
style="font-size:11pt;font-family:Verdana,sans-serif">Thanks<u></u><u></u></span></font></p></div><div><p><font \
size="2" face="Verdana"><span \
style="font-size:11pt;font-family:Verdana,sans-serif"><u></u>  \
<u></u></span></font></p></div><div><div><div><div><p><b><font size="2" \
color="#444444" face="Bookman Old Style"><span \
style="font-size:10pt;font-family:&quot;Old \
serif&quot;;color:rgb(68,68,68);font-weight:bold">Stanford</span></font></b><u></u><u></u></p></div><div><p><font \
size="2" face="Calibri"><span style="font-size:11pt"><u></u>  \
<u></u></span></font></p></div></div></div></div></div></div></div></div></div></blockquote></div></div>
 </div></div></div>
            </div>
        </div></div></blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic