Published on :
Data Management CREATION_INTERNE

Generation of Test Data Sets (JES)

This code is also available in: Deutsch Español Français
Awaiting validation
This script creates a series of tables in the 'JES' library for testing or demonstration purposes. It uses various methods: direct entry (DATALINES) for contacts, arithmetic loops for statistical distributions (Poisson), and random generation (RANUNI, RANPOI) to simulate operational data (units, failures, rates). It also includes subsequent transformations with the LAG function to simulate dependencies between rows and a sorting procedure.
Data Analysis

Type : CREATION_INTERNE


All data is generated within the script via DATALINES, generation loops, or random functions (RANUNI, RANPOI).

1 Code Block
DATA STEP Data
Explanation :
Creation of the JES.Contacts table with static data provided via DATALINES.
Copied!
1DATA JES.Contacts;
2 INPUT Name $15. City $10. State $5. Number $15.;
3 DATALINES;
4John X. Doe Lodi nj 201-555-O123
5Mary Murphy San Jose CA 408.555.678
6;
7RUN;
2 Code Block
DATA STEP Data
Explanation :
Creation of the JES.TimeStamp table containing character strings representing dates/times.
Copied!
1DATA JES.TimeStamp;
2 Time = "Tue Apr 03 08:25:00 MST 2004"; OUTPUT;
3 Time = "Tue Mar 26 17:52:31 MST 2004"; OUTPUT;
4 Time = "Tue Jun 03 08:25:00 MDT 2004"; OUTPUT;
5RUN;
3 Code Block
DATA STEP Data
Explanation :
Generation of statistical data (Poisson Distribution) using CDF and PDF functions in a loop.
Copied!
1DATA JES.Poisson;
2 DO K = 0 TO 5;
3 F = CDF('POISSON', K, 5);
4 P = PDF('POISSON', K, 5);
5 OUTPUT;
6 END;
7RUN;
4 Code Block
DATA STEP Data
Explanation :
Simulation of unit data (JES.Units) with random serial numbers and installation dates via RANUNI.
Copied!
1DATA JES.Units; FORMAT SN $4. Install MMDDYY10.;
2 SEED=12345;
3 DO I=1 TO 10;
4 CALL RANUNI(SEED, X); CALL RANUNI(SEED, Y); CALL RANUNI(SEED, Z);
5 SN=put(FLOOR(99*X), Z4.0);
6 Install = '01JUN2006'd + ROUND(21*Y);
7 Loc ="CA"; IF Z<.45 THEN Loc="NY";
8 OUTPUT;
9 END;
10 DROP i X Y Z SEED;
11RUN;
5 Code Block
DATA STEP Data
Explanation :
Modification of JES.Units to introduce duplicates or shifted values using the LAG3 function on the serial number.
Copied!
1DATA JES.Units; SET JES.Units;
2 L=LAG3(SN);
3 IF _N_ in (4,6,8) THEN SN=L;
4 DROP L;
5RUN;
6 Code Block
DATA STEP Data
Explanation :
Simulation of failure data (JES.Fails) with random dates and locations.
Copied!
1DATA JES.Fails; FORMAT SN $4. Fail MMDDYY10. Loc $6.;
2 SEED=12345;
3 DO I=1 TO 10;
4 CALL RANUNI(SEED, X); CALL RANUNI(SEED, Y); CALL RANUNI(SEED, Z);
5 SN=put(FLOOR(99*X), Z4.0);
6 Fail = '01JUL2006'd + FLOOR(90*Y);
7 Loc ="Top"; IF Z<.45 THEN Loc="Bottom";
8 OUTPUT;
9 END;
10 DROP i X Y Z SEED;
11RUN;
7 Code Block
DATA STEP Data
Explanation :
Filtering and modification of JES.Fails: deletion of certain rows (4, 8, 10) and modification of row 5 via LAG4.
Copied!
1DATA JES.Fails; SET JES.Fails; L=Lag4(SN);
2 IF _N_=5 THEN SN=L;
3 IF _N_ NE 4; IF _N_ NE 8; IF _N_ NE 10;
4 DROP L;
5RUN;
8 Code Block
PROC SORT
Explanation :
Sorting the JES.Fails table by failure date.
Copied!
1PROC SORT DATA=JES.Fails; BY Fail; RUN;
9 Code Block
DATA STEP Data
Explanation :
Generation of the JES.Rates table simulating failure rates by vendor and region, using RANPOI (Poisson distribution).
Copied!
1DATA JES.Rates;
2 FORMAT Vendor $15. GEO $4. QTR $2. Rate 8.4 Test 8.0; SEED=12345;
3 Vendor = "ChiTronix"; GEO = "APAC"; Test = 5000;
4 DO i=1 TO 4; QTR="Q"||PUT(i, 1.0); Fail=RANPOI(SEED, .05*Test); OUTPUT; END;
5 Vendor = "Duality"; GEO = "EMEA"; Test = 1000; Fail = 7;
6 DO i=2 TO 4; QTR="Q"||PUT(i, 1.0); Fail=RANPOI(SEED, .02*Test); OUTPUT; END;
7 Vendor = "Empirical"; GEO="AMER"; Test = 7000; Fail = 100;
8 DO i=1 TO 3; QTR="Q"||PUT(i, 1.0); Fail=RANPOI(SEED, .01*Test); OUTPUT; END;
9RUN;
10 Code Block
DATA STEP Data
Explanation :
Final calculation of the failure rate (Rate) in the JES.Rates table.
Copied!
1DATA JES.Rates; SET JES.Rates; FORMAT Rate percent8.2;
2 IF Test>0 THEN Rate=Fail/Test;
3 drop SEED i;
4RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.