Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am trying to use For loop using a variable which has been assigned a value using count function:
Let vLoop = '=Count(DISTINCT abc)'
For i = $(vLoop) to 60
...
Next i
I have tried with different combinations of Let and Set but none of them seems to work.
Let vLoop = 'Count(DISTINCT abc)'
Let vLoop = Count(DISTINCT abc)
Set vLoop = '=Count(DISTINCT abc)'
Set vLoop = 'Count(DISTINCT abc)'
Set vLoop = Count(DISTINCT abc)
Any ideas on what might I be doing wrong here.
Thanks,
S
Hi,
You'll need to use the Peek function in the script to assign the value to the variable.
Try like this, after loading your initial table (let's say it's labeled T_Data):
T_Count:
Load count(distinct abc) as Cnt
resident T_Data;
let vLoop = peek('Cnt', 0, 'T_Count');
drop table T_Count;
for i = $(vLoop) to 60
...
next
is abc a field?
EDIT
if yes try with
t:
load * inline [
abc
a
b
c
c
d
d
e
e
];
tmp: load count (distinct abc) as distinctabc resident t;
let v = peek('distinctabc');
for i = v to 60
trace $(i);
next;
Hi,
You'll need to use the Peek function in the script to assign the value to the variable.
Try like this, after loading your initial table (let's say it's labeled T_Data):
T_Count:
Load count(distinct abc) as Cnt
resident T_Data;
let vLoop = peek('Cnt', 0, 'T_Count');
drop table T_Count;
for i = $(vLoop) to 60
...
next
Yes it was one of a field. Thanks your solution worked out.
Best,
S