BookmarkSubscribeRSS Feed
Eitan123
Obsidian | Level 7

Hey, I'm a bit new to SAS.
One of my SAS users asked me to create a calculated item which could be used for campaigns in Customer Intelligence Studio in order to define certain populations.

The item can be translated to the following MS SQL querry:

select count(*)
from X
where 1=1
and DATE > getdate() - 30 * 6
and TYPE = 'A'

In other words, we need the amount of records of type A of the last half of the year.

I've managed to create an item that counts all records of table X, but:

1) I don't know how to include my WHERE conditions.

2) I don't know how to define the item as FLOAT (it will be a numerator of another item for percentage calculations).


Note:

a) The item must be created in Information Maps, not Customer Intelligence Studio.

b) I've been asked by the user to create a single item to be used in Customer Intelligence studio.

2 REPLIES 2
yabwon
Amethyst | Level 16

About 1), try this:

data X;
  do I = 1 to 365;
    date = today() - I;
    do type = "A", "B";
      output;
    end;
  end;
run;


proc sql;
select count(*)
from X
where DATE > (today() - 30 * 6)
 and TYPE = 'A'
;
run;

About 2), it is already a "float" since SAS doesn't distinguish numeric types, they all are just "numbers".

B

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Eitan123
Obsidian | Level 7

Hey yabwon,

about 1): where do I write this code? within the expression of the item in information maps?