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

List:       sas-l
Subject:    Re: Counting total and create text string
From:       "data _null_," <datanull () GMAIL ! COM>
Date:       2008-05-30 21:04:37
Message-ID: 7367b4e20805301404t42f60b05o867d080fd1bad9ac () mail ! gmail ! com
[Download RAW message or body]

Would splitting the NAME into the root and number parts be helpful.  I
don't really understand what you want to accomplish.

data work.mayHave;
   input root:$8. @@;
   do i = 1 to floor(ranuni(1234)*1e2);
      name = catx('_',root,i);
      output;
      end;
   keep name;
   cards;
OFFER SVA LVA
;;;;
   run;
data work.mayNeed;
   set work.MayHave;
   length root $10;
   root = scan(name,1,'_');
   n    = input(scan(name,2,'_'),f8.);
   run;
proc print;
   run;


On 5/30/08, KJ <krutic@gmail.com> wrote:
> Hello,
>
> I need to sort offers, SVA and LTA based on sort keys that I create.
> Currently I am hardcoding these sort keys as shown below:
>
> *********************
> data one;
> set two;
>
> if name = 'OFFER_1'                     then srtkey = 4;
> if name = 'OFFER_2'                     then srtkey = 5;
> .
> .
> .
>
> if name = 'SVA_1'                     then srtkey = 40;
> if name = 'SVA_2'                     then srtkey = 41;
> .
> .
> .
>
> if name = 'LVA_1'                     then srtkey = 80;
> if name = 'LVA_2'                     then srtkey = 81;
> .
> .
> .
>
> if srtkey = . then srtkey  = 999;
>
> proc sort data= one; by sortkey;run;
>
> ****************
> The number goes as high as 40 currently but likely to go higher. Is
> there a way to count the total number of these offers (which will be
> the same as the number of sva and lva) and put it in a macro variable
> which prints out the text string
> if name = xxxx_yy'                     then srtkey = xx; ?
>
> I have a counter that counts the total number of offers and it is
> stored in &total. How can I use that for this?
>
> So I'm thinking something along the lines of retaining the previous
> number as long as its less than &total and adding one to that number
> to get the next till they reach &total. Basically a loop that gives me
> the above strings without having to type them individually over 200
> times!
>
> Thank you,
> KJ
>
[prev in list] [next in list] [prev in thread] [next in thread] 

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