I have the following SAS PROC MEANS statement that works great as it is.
proc means data=MBA_NODUP_APPLICANT_&TERM. missing nmiss n mean median p10 p90 fw = 8;
where ENR = 1;
by SRC_TYPE;
var gmattotal greverb2 grequant2 greanwrt;
run;
However, I am trying to add new variable calculating nmiss/(nmiss+n). I don't see any examples of this online, but also nothing that says that it cannot be done.
To calculate the percent missing, which is what your formula means, just use the OUTPUT statement to generate a dataset with the NMISS and N values. Then add a step to do the arithmetic yourself.
Or you could create a new binary variable using the MISSING() function and take the MEAN of that. The mean of a 1/0 variable is the same are the percent that were 1 (TRUE).
Example:
data test;
set sashelp.cars;
missing_cylinders=missing(cylinders);
run;
proc means data=test nmiss n mean;
var cylinders missing_cylinders ;
run;
So 2/428 is a little less than 0.5%.
The MEANS Procedure
N
Variable Miss N Mean
------------------------------------------------
Cylinders 2 426 5.8075117
missing_cylinders 0 428 0.0046729
Let's say I have stores all around the world and I want to know what was my top losses sales across the world per store. What is the code for that?!
here is my try:
proc sort data= store out=sorted_store;
by store descending amount;
run;
and
data calc1;
do _n_=1 by 1 until(last.store);
set sorted_store;
by store;
if _n_ <= 5 then "Sum_5Largest_Losses"n=sum(amount);
end;
run;
but this just prints out the 5:th amount and not 1.. TO .. 5! and I really don't know how to select the top 5 of EACH store . I think a kind of group by would be a perfect fit. But first things, first. How do I selct i= 1...5 ? And not just = 5?
There is also way of doing it with proc sql:
data have;
input store$ amount;
datalines;
A 100
A 200
A 300
A 400
A 500
A 600
A 700
B 1000
B 1100
C 1200
C 1300
C 1400
D 600
D 700
E 1000
E 1100
F 1200
;
run;
proc sql outobs=4; /* limit to first 10 results */
select store, sum(amount) as TOTAL_AMT
from have
group by 1
order by 2 desc; /* order them to the TOP selection*/
quit;
The data step sum(,) function adds up its arguments. If you only give it one argument then there is nothing to actually sum so it just returns the input value.
data calc1;
do _n_=1 by 1 until(last.store);
set sorted_store;
by store;
if _n_ <= 5 then Sum_5Largest_Losses=sum(Sum_5Largest_Losses,amount);
end;
run;
I would highly recommend learning the basic methods before getting into DOW loops.
Add a counter so you can find the first 5 of each store
As the data step loops the sum accumulates
Output sum for counter=5
proc sort data= store out=sorted_store;
by store descending amount;
run;
data calc1;
set sorted_store;
by store;
*if first store then set counter to 1 and total sum to 0;
if first.store then do ;
counter=1;
total_sum=0;
end;
*otherwise increment the counter;
else counter+1;
*accumulate the sum if counter <= 5;
if counter <=5 then total_sum = sum(total_sum, amount);
*output only when on last/5th record for each store;
if counter=5 then output;
run;
Overview:
What I have: 81A8221704654BAC9B24CDFE5A834541 (hex string)
What I want: 172343408754022659539630353407870715201 (decimal equivalent as string)
Detail:
I am exporting data from SAS to a 3rd party platform that performs better when the unique key is in numeric format. The key to the data I'm using is currently stored as a 32 char string containing a hex value, e.g. 81A8221704654BAC9B24CDFE5A834541.
The issue I'm facing is that the largest integer value available in SAS on Linux is 9007199254740992 in decimal (or 20000000000000 in hex). The 32 character hex value when converted to decimal will be much larger and any attempt to do conversion using numeric values will lose precision.
The only two approaches I can think of, are to either write some functions that do addition of two strings (ugly+slow), or perhaps someone has a clever way using some bitwise logical functions?
Any suggestions?
You can use Java BigInteger.
Groovy
Write data to file and read conversion back
data have;
input hexstr $32.;
datalines;
81A8221704654BAC9B24CDFE5A834540
81A8221704654BAC9B24CDFE5A834541
81A8221704654BAC9B24CDFE5A834542
81A8221704654BAC9B24CDFE5A834543
;
proc export data=have replace outfile='c:\temp\have-hexstr.dat' dbms=tab;
putnames=no;
run;
proc groovy;
submit;
File out = new File("c:\\temp\\want-decstr.dat");
out.write "hexstr,decstr\n";
new File ("c:\\temp\\have-hexstr.dat").eachLine { line ->
out.append(line+",\""+new BigInteger(line, 16).toString()+"\"\n");
}
endsubmit;
quit;
options source;
proc import datafile='c:\temp\want-decstr.dat' replace out=want dbms=csv;
run;
JavaObj
You could create a jar that contains a Converter class for performing the conversion and call the method from a JavaObj. The jar would have to be added to the SAS session classpath at startup.
public class Converter
{
public string hexStrToDecStr(hexStr)
{
return new java.math.BigInteger(hexStr,16).toString();
}
}
data want;
set have;
if _n_ = 1 then do;
declare javaobj j('Converter');
end;
length decStr $50;
j.callStringMethod('hexStrToDecStr', hexStr, decStr);
run;
Ideal JavaObj
Can't do this because JavaObj can only pass double values to methods :(
data want;
set have;
length decStr $50;
* wont work, cause 16 passed as double! :(;
declare javaobj j ('java/math/BigInteger', hexStr, 16);
j.callStringMethod('toString', decStr);
j.delete();
run;
Ok, here goes... I tested four approaches:
Ugly+Slow. My own SAS code that implements the ability to convert a 32 char string containing a hex value into a very big integer.
Process externally to SAS then join the data back. I chose Java for it's ubiquity as well as its existing support for BigIntegers, and the resulting simple code.
Run some Python code from inside a SAS proc fcmp function to perform the conversion. The FCMP function can then be used within a datastep.
(per Richard's answer) Use proc groovy to perform the conversion.
Results:
My SAS implementation took ~15 minutes to take the same hex string 1
million times and convert it to a big integer (stored as a string).
The java implementation took ~3 seconds to generate 1 million hex
strings and convert them to big integers. This doesn't include any additional time that would be required to export the data, and join it back.
The proc fcmp + python solution took ~90 seconds to process 1 million UUIDs or hex string equivalents and convert them all within a SAS datastep.
Richard's proc groovy solution took ~10 seconds to process 1 million observations including writing them to disk and reading them back in. Joining these back to a wider dataset would incurr additional time/IO cost.
With the huge disparity in timing, the vanilla SAS option is clearly not the solution use unless you don't have the ability to implement any of the other solutions. The one advantage it does have is that it's all done natively within SAS - so if your admins have your system on lockdown, you can still achieve the conversion, albeit slower.
Between the other 3 solutions, I think the best solution depends on your use case:
The proc fcmp solution has the advantage that it makes for cleaner / self-contained SAS code that's easy to maintain/read/use and runs from within a datastep (something none of the other solutions can claim), but at the cost of running a little slower. I think this would be my preferred choice if I wasn't dealing with big-data performance issues.
The proc groovy solution is also nice in that all of the code can live within SAS and no external programs/JAR files are required. The downside is that it does incur the additional complexity of having to dump the hex values to disk, convert them, read them back in, and finally join back to the original dataset. Even with the additional steps, depending on the size/width of the original dataset, this is likely to be faster than the above 2 options.
The Java solution to me doesn't offer any benefits over the proc groovy solution . It may run marginally faster (untested), but even if it did, it requires compilation of the JAR file, and existing external .java source file, etc.. so leaves a bit more of a mess lying around.
Disclaimer:
My expertise isn't low level computer science coding - I'm sure there's ways to improve my vanilla SAS code approach but I don't know how so if you can suggest any improvements feel free to chime in.
#1 - SAS Implementation
The approach I took in SAS was as follows:
Slice the 32 character have string into 4 8-character strings.
Convert each of these 8 character strings from hex to decimal. These are small enough that SAS is able to store them as numeric values without losing precision and we can make use of the existing hex informat.
Multiply each of these 4 numerics by the appropriate base-16 exponents to 'resize' them accordingly. The exponents were precalculated outside of SAS using a big number calculator as 16^16 and 16^24 are too big for SAS to handle. To multiply these numbers together I created an FCMP function called multiply_strings.
Add the 4 resulting strings from step 3 together using an FCMP function I created called add_strings.
Below is some test code that performs the above steps and shows the workings, the steps are commented:
data _null_;
length front back final $80;
* CALCULATED USING A BIG NUMBER CALCULATOR. DONT PERFORM THESE CALCULATIONS IN SAS;
exp1 = '1'; * 16 ** 0;
exp2 = '4294967296'; * 16 ** 8;
exp3 = '18446744073709551616'; * 16 ** 16;
exp4 = '79228162514264337593543950336'; * 16 ** 24;
have = '81A8221704654BAC9B24CDFE5A834541';
correct = '172343408754022659539630353407870715201'; * TESTED USING THE SEARCH TERM: 81A8221704654BAC9B24CDFE5A834541 hex as decimal ;
* STEP1;
hex1 = upcase(substr(have,25,8));
hex2 = upcase(substr(have,17,8));
hex3 = upcase(substr(have, 9,8));
hex4 = upcase(substr(have, 1,8));
*STEP2;
part1 = input(hex1,hex8.);
part2 = input(hex2,hex8.);
part3 = input(hex3,hex8.);
part4 = input(hex4,hex8.);
*STEP3;
product1 = part1;
product2 = multiply_strings(put(part2,32.0), exp2, 0);
product3 = multiply_strings(put(part3,32.0), exp3, 0);
product4 = multiply_strings(put(part4,32.0), exp4, 0);
* STEP4;
* SHOULD CHANGE ADD STRINGS TO ACCEPT 4 PARAMS BUT WILL SEE HOW PERFORMANCE COMPARES FIRST;
front = add_strings(product1, product2);
back = add_strings(product3, product4);
final = add_strings(front , back );
put #3 final=;
put correct=;
put '-';
put have=;
put hex1=;
put hex2=;
put hex3=;
put hex4=;
put '-';
put part1=;
put part2=;
put part3=;
put part4=;
put '-';
put product1=;
put product2=;
put product3=;
put product4=;
put '-';
put exp1=;
put exp2=;
put exp3=;
put exp4=;
%runquit;
And the results from the above step:
final=172343408754022659539630353407870715201
correct=172343408754022659539630353407870715201
-
have=81A8221704654BAC9B24CDFE5A834541
hex1=5A834541
hex2=9B24CDFE
hex3=04654BAC
hex4=81A82217
-
part1=1518552385
part2=2602880510
part3=73747372
part4=2175279639
-
product1=1518552385
product2=11179286665845800960
product3=1360398897392653722978353152
product4=172343408752662260631058413017528008704
-
exp1=1
exp2=4294967296
exp3=18446744073709551616
exp4=79228162514264337593543950336
The code I used to run it 1 million times was this (I smashed it all together on the off-chance it would run faster, it didn't):
data _null_;
length front back final $80;
* CALCULATED USING A BIG NUMBER CALCULATOR. DONT PERFORM THESE CALCULATIONS IN SAS;
part1_exp = '1'; * 16 ** 0;
part2_exp = '4294967296'; * 16 ** 8;
part3_exp = '18446744073709551616'; * 16 ** 16;
part4_exp = '79228162514264337593543950336'; * 16 ** 24;
have = '81A8221704654BAC9B24CDFE5A834541';
correct = '172343408754022659539630353407870715201'; * TESTED USING THE SEARCH TERM: 81A8221704654BAC9B24CDFE5A834541 hex as decimal ;
do blah=1 to 1000000;
front = add_strings(input(upcase(substr(have,25,8)),hex8.), multiply_strings(put(input(upcase(substr(have,17,8)),hex8.),32.0), part2_exp, 0));
back = add_strings(multiply_strings(put(input(upcase(substr(have, 9,8)),hex8.),32.0), part3_exp, 0), multiply_strings(put(input(upcase(substr(have, 1,8)),hex8.),32.0), part4_exp, 0));
final = add_strings(front , back );
end;
run;
FCMP function: add_strings()
This function simply performs addition as you would write it out by hand. Obviously we're trying to avoid converting any significant part of it into a SAS numeric. Perhaps chunking it and using numeric addition would be faster but I'd already spent enough time writing it this way and time constraints etc.....
proc fcmp outlib=work.funcs.funcs;
function add_strings(str1 $, str2 $ ) $;
length result rev1 rev2 $40 digit $1;
len = max(lengthn(cats(str1)), lengthn(cats(str2)));
rev1 = cats(reverse(str1));
rev2 = cats(reverse(str2));
max_result_length = len + 1;
carry = 0;
result = '';
do cnt=1 to max_result_length;
s = sum(input(substr(rev1,cnt,1),best.), input(substr(rev2,cnt,1),best.), carry);
digit = mod(s,10);
carry = floor(s/10);
result = cats(digit, result);
end;
/* REMOVE LEADING ZEROS */
result_len = lengthn(cats(result));
do first_non_zero=1 to result_len;
if substr(result, first_non_zero, 1) ne '0' then do;
leave;
end;
end;
result = cats(substr(result,min(first_non_zero,result_len),result_len));
return(result);
endsub;
run;
FCMP function: multiply_strings()
This function multiplies two large strings containing very big integers together... It should be accurate to any number where the result is no more than 80 characters but I haven't tested the boundary conditions. The third option is simply to print debugging information to the log, set to 1 to print it.
This was a little trickier than the add_strings() function as typically multiplication by hand (at least how I do it) requires you to add numbers together as part of the process. We want to avoid doing this as these numbers will be very large and we would have had to use the add_strings() function to do it (which I already knew was slow from testing).
Instead I found this approach to multiplication which would avoid having to add any numbers together that would be too large for SAS to store: https://www.youtube.com/watch?v=b_xUE4wkVKY . I don't know if this approach has a proper name or not, I couldn't find a lot of information on it, my google-fu was lacking.
proc fcmp outlib=work.funcs.funcs;
function multiply_strings(str_a $, str_b $, debug ) $;
length result $80 rev_a rev_b $40 digit $1;
array a [40] a1-a40; * STR_A AS AN ARRAY;
array b [40] b1-b40; * STR_B AS AN ARRAY;
array base [80] base1-base80; * PRODUCT OF STR_A AND STR_B ELEMENTS.;
array r [80] r1-r80; * RESULT;
**
** CANT DYNAMICALLY SIZE ARRAY P UNFORTUNATELY (AFAIK).
** LOTS OF WASTED SPACE AND PROBABLY SLOWER BUT EASIER TO CODE/DEBUG I SUPPOSE.
** 39 LEVELS. 2 ROWS PER LEVEL. 80 CELLS PER ROW.
*;
array p [39,2,80] p1-p6240;
a_len = lengthn(str_a);
b_len = lengthn(str_b);
rev_a = reverse(str_a);
rev_b = reverse(str_b);
max_len = max(a_len, b_len);
* INITIALIZE A+B ARRAYS;
do cnt=41-(max_len) to 40;
a[cnt] = input(substr(rev_a,41-cnt,1),best.);
b[cnt] = input(substr(rev_b,41-cnt,1),best.);
if debug then do;
put cnt= max_len= a[cnt] b[cnt];
end;
end;
* CALCULATE BASE;
do cnt=41-(max_len) to 40;
product = a[cnt] * b[cnt];
left = cnt*2-1;
right = cnt*2-0;
base[left] = floor(product/10);
base[right] = mod(product,10);
if debug then do;
put cnt= a[cnt] b[cnt] product= base[left] base[right] left= right=;
end;
end;
* CALCULATE PYRAMID. BOTTOM (LVL=40) OF PYRAMID IS POINTY. REMEMBER EACH LEVEL IS 2 BLOCKS HIGH (MIDDLE DIMENSION OF ARRAY).;
do lvl=1 to max_len-1;
start_cell = 81-(max_len*2)+lvl;
end_cell = 80-lvl;
cnt_start = 41-(max_len);
cnt_end = 40;
cnt = cnt_start;
iter = 0;
do while (cnt + lvl le cnt_end); * CALCULATE THE PRODUCTS;
product1 = a[cnt]*b[cnt+lvl];
product2 = b[cnt]*a[cnt+lvl];
cell1 = start_cell+(iter*2);
cell2 = cell1+1;
p[lvl,1,cell1] = floor(product1/10);
p[lvl,1,cell2] = mod(product1,10);
p[lvl,2,cell1] = floor(product2/10);;
p[lvl,2,cell2] = mod(product2,10);;
if debug then do;
put lvl= cnt_start= cnt_end= cnt= product1= product2= start_cell= end_cell= cell1= cell2= iter=;
end;
cnt = cnt + 1;
iter = iter + 1;
end;
end;
* CALCULATE RESULT. SIMPLY PERFORM ADDITION USING THE BASE AND THE PYRAMID ELEMENTS (BY COLUMN POSITION). CARRY FOR ANY NUMBERS >= 10.;
carry = 0;
do cell=80 to 81-(max_len*2) by -1;
r[cell] = sum(base[cell], carry);
do lvl=1 to max_len-1;
do row=1 to 2;
r[cell] = sum(0,r[cell],p[lvl,row,cell]);
end;
end;
carry = floor(r[cell]/10);
r[cell] = mod(r[cell],10);
end;
* OUTPUT THE FINAL CALCULATIONS TO THE LOG;
if debug eq 1 then do;
option linesize=200;
put a[*];
put b[*];
put ' ';
put base[*];
put ' ';
do lvl=1 to max_len-1;
do row=1 to 2;
do cell=1 to 80;
put p[lvl,row,cell] z1. #;
end;
put ;
end;
end;
put ' ';
put r[*];
end;
* TRIM MISSING VALUES AND ZEROES FROM THE FRONT OF THE RESULT.;
result = cats(of r[*]);
do first_non_zero=1 to 80;
if substr(result, first_non_zero, 1) not in (0,.) then do;
leave;
end;
end;
result = cats(substr(result,min(first_non_zero,80),80));
return(result);
endsub;
run;
#2 - The JAVA solution
Much more concise =P. Create a file called test.java containing the following:
import java.math.BigInteger;
import java.util.UUID;
public class test {
public static void main(String[] args)
{
int reps = 1000000;
for (int i = 0; i < reps; i++) {
String s = UUID.randomUUID().toString().replaceAll("\\-", "");
BigInteger big = new BigInteger(s, 16);
/*System.out.println(s);*/
/*System.out.println(big);*/
}
}
}
Compile it from the command line using javac test.java then execute it by java test.
#3 - proc fcmp+Python
This is the nicest approach IMO. The code is fast-enough for most use-cases, it's simple to call and can be run from inside a datastep, and works on both UUID formatted strings and 32 character hex strings.
If you're running a SAS version below SAS9.4M7 then you WILL need to define the MASM2PATH and MAS_PYPATH environment variables in the appropriate sasv9.cfg / sasv9_usermods.cfg file(s).
proc fcmp outlib=work.funcs.funcs;
/* SYSTEM REQUIREMENTS: SAS94M6. PYTHON2.7 OR ABOVE. MAS_M2PATH AND MAS_PYPATH MUST BE SET AS SYSTEM ENVIRONMENT VARIABLES */
function uuid_to_decimal(str $) $40;
* CREATE THE INNER PYTHON FUNCTION CALL;
declare object py(python);
submit into py;
def u2d( s ):
"Output: u2d_output"
import uuid
return str(uuid.UUID(s).int)
endsubmit;
rc = py.publish(); * PUBLISH THE CODE TO THE PYTHON INTERPRETER;
rc = py.call("u2d", str); * CALL THE PYTHON FUNCTION FROM SAS;
return(py.results["u2d_output"]);
endsub;
run;
option cmplib=work.funcs;
data _null_;
length test1 test2 $40;
do cnt=1 to 500000;
test1 = uuid_to_decimal("a341b0d0-1ec5-11eb-b64d-02b1159b38e9");
test2 = uuid_to_decimal("a341b0d01ec511ebb64d02b1159b38e9");
end;
put test1= test2=;
run;
#4 - proc groovy (thanks to #Richard for this solution)
A faster solution than the FCMP/Python solution but the big downside to me is that you need to dump the values to convert then import and join them back to the original dataset afterwards. The hidden performance cost will then depend on the size and width of the dataset you are working with.
%let work = %sysfunc(pathname(work));
data have;
input hexstr $32.;
do i = 1 to 1000000;
output;
end;
drop i;
datalines;
81A8221704654BAC9B24CDFE5A834540
;
run;
proc export data=have replace outfile="&work/have.txt" dbms=tab;
putnames=no;
run;
proc groovy;
submit "&work"; * PASS IN OUR WORK PATH AS THE FIRST PARAMETER;
File out = new File(args[0]+"/want.txt");
out.write "hexstr,decstr\n";
new File (args[0]+"/have.txt").eachLine { line ->
out.append(line+",\""+new BigInteger(line, 16).toString()+"\"\n");
}
endsubmit;
quit;
options source;
proc import datafile="&work/want.txt" replace out=want dbms=csv;
run;
I have a SAS issue that I know is probably fairly straightforward for SAS users who are familiar with array programming, but I am new to this aspect.
My dataset looks like this:
Data have;
Input group $ size price;
Datalines;
A 24 5
A 28 10
A 30 14
A 32 16
B 26 10
B 28 12
B 32 13
C 10 100
C 11 130
C 12 140
;
Run;
What I want to do is determine the rate at which price changes for the first two items in the family and apply that rate to every other member in the family.
So, I’ll end up with something that looks like this (for A only…):
Data want;
Input group $ size price newprice;
Datalines;
A 24 5 5
A 28 10 10
A 30 14 12.5
A 32 16 15
;
Run;
The technique you'll need to learn is either retain or diff/lag. Both methods would work here.
The following illustrates one way to solve this, but would need additional work by you to deal with things like size not changing (meaning a 0 denominator) and other potential exceptions.
Basically, we use retain to cause a value to persist across records, and use that in the calculations.
data want;
set have;
by group;
retain lastprice rateprice lastsize;
if first.group then do;
counter=0;
call missing(of lastprice rateprice lastsize); *clear these out;
end;
counter+1; *Increment the counter;
if counter=2 then do;
rateprice=(price-lastprice)/(size-lastsize); *Calculate the rate over 2;
end;
if counter le 2 then newprice=price; *For the first two just move price into newprice;
else if counter>2 then newprice=lastprice+(size-lastsize)*rateprice; *Else set it to the change;
output;
lastprice=newprice; *save the price and size in the retained vars;
lastsize=size;
run;
Here a different approach that is obviously longer than Joe's, but could be generalized to other similar situations where the calculation is different or depends on more values.
Add a sequence number to your data set:
data have2;
set have;
by group;
if first.group the seq = 0;
seq + 1;
run;
Use proc reg to calculate the intercept and slope for the first two rows of each group, outputting the estimates with outest:
proc reg data=have2 outest=est;
by group;
model price = size;
where seq le 2;
run;
Join the original table to the parameter estimates and calculate the predicted values:
proc sql;
create table want as
select
h.*,
e.intercept + h.size * e.size as newprice
from
have h
left join est e
on h.group = e.group
order by
group,
size
;
quit;
I've been trying to find the simplest way to generate simulated time series datasets in SAS. I initially was experimenting with the LAG operator, but this requires input data, so is proabably not the best way to go. (See this question: SAS: Using the lag function without a set statement (to simulate time series data.))
Has anyone developed a macro or dataset that enables time series to be genereated with an arbitrary number of AR and MA terms? What is the best way to do this?
To be specific, I'm looking to generate what SAS calls an ARMA(p,q) process, where p denotes the autoregressive component (lagged values of the dependent variable), and q is the moving average component (lagged values of the error term).
Thanks very much.
I have developed a macro to attempt to answer this question, but I'm not sure whether this is the most efficient way of doing this. Anyway, I thought it might be useful to someone:
%macro TimeSeriesSimulation(numDataPoints=100, model=y=e,outputDataSetName=ts, maxLags=10);
data &outputDataSetName (drop=j);
array lagy(&maxlags) _temporary_;
array lage(&maxlags) _temporary_;
/*Initialise values*/
e = 0;
y=0;
t=1;
do j = 1 to 10;
lagy(j) = 0;
lage(j) = 0;
end;
output;
do t = 2 to &numDataPoints; /*Change this for number of observations*/
/*SPECIFY MODEL HERE*/
e = rannorm(-1); /*Draw from a N(0,1)*/
&model;
/*Update values of lags on the moving average and autoregressive terms*/
do j = &maxlags-1 to 1 by -1; /*Note you have to do this backwards because otherwise you cascade the current value to all past values!*/
lagy(j+1) = lagy(j);
lage(j+1) = lage(j);
end;
lagy(1) = y;
lage(1) = e;
output;
end;
run;
%mend;
/*Example 1: Unit root*/
%TimeSeriesSimulation(numDataPoints=1000, model=y=lagy(1)+e)
/*Example 2: Simple process with AR and MA components*/
%TimeSeriesSimulation(numDataPoints=1000, model=y=0.5*lagy(1)+0.5*lage(1)+e)