Hi,
i would like to create a sequence column in VA. Is it possible?
ID | Object | Sequence |
1 | A | 1 |
1 | A | 2 |
1 | A | 3 |
1 | B | 1 |
2 | B | 1 |
2 | B | 2 |
2 | B | 3 |
1 | A | 4 |
I have to create it in VA because that matrix has to change based on filter someone might choose.
For example, if i choose a shorter period of time it could change like this (and the sequence accordingly):
ID | Object | Sequence |
1 | A | 1 |
1 | B | 1 |
2 | B | 1 |
2 | B | 2 |
1 | A | 2 |
Can someone help me?
Thank you
you want to show as a list table ?
Hi @akash1088,
yes.
Can i ask you why are you asking me this question? Would you suggest something else?
Thanks
Yes.
I have to enumerate the record based on ID and Object.
I'm sorry but i'm new on sas VA: i don't understand your piece of code. 😞
Holding CTRL key click on the column name in list table as per the sequence you want.
i have to create the Sequence column, not just order the table.
One more question, do you know if i can take the value of a variable of the previous row?
In SAS Base i would use:
data want;
set have;
prev_date = lag(created);
if first.id then prev_date = created;
run;
can you just show one sample what exactly you want.
and sorry I don't know how to create that sequence column in sas va but in base sas you can use this one.
hope this gonna help u.
Data have;
Infile datalines dlm=' ';
input ID:1 Object:$1. ;
datalines;
1 A
1 A
1 A
1 B
2 B
2 B
2 B
1 A
;
run;
Proc Sort data=have;
by ID Object;
Run;
data new;
set have;
by ID Object;
if first.object then sequence=0;
Sequence+1;
run;
Thank you, but the problme is to create it in SAS VA.
In BASE is quite simple as you posted, but in VA it seems impossible.
Any workaround?
Unfortunately the VA query engine doesn't allow such sequence or row based calculation and I'm not aware of a work-around other than calculating such as part of the data preparation step.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.