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!
DATA JES.Contacts;
INPUT Name $15. City $10. State $5. Number $15.;
DATALINES;
John X. Doe Lodi nj 201-555-O123
Mary Murphy San Jose CA 408.555.678
;
RUN;
1
DATA JES.Contacts;
2
INPUT Name $15. City $10. State $5. Number $15.;
3
DATALINES;
4
John X. Doe Lodi nj 201-555-O123
5
Mary Murphy San Jose CA 408.555.678
6
;
7
RUN;
2 Code Block
DATA STEP Data
Explanation : Creation of the JES.TimeStamp table containing character strings representing dates/times.
Copied!
DATA JES.TimeStamp;
Time = "Tue Apr 03 08:25:00 MST 2004"; OUTPUT;
Time = "Tue Mar 26 17:52:31 MST 2004"; OUTPUT;
Time = "Tue Jun 03 08:25:00 MDT 2004"; OUTPUT;
RUN;
1
DATA 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;
5
RUN;
3 Code Block
DATA STEP Data
Explanation : Generation of statistical data (Poisson Distribution) using CDF and PDF functions in a loop.
Copied!
DATA JES.Poisson;
DO K = 0 TO 5;
F = CDF('POISSON', K, 5);
P = PDF('POISSON', K, 5);
OUTPUT;
END;
RUN;
1
DATA JES.Poisson;
2
DO K = 0 TO 5;
3
F = CDF('POISSON', K, 5);
4
P = PDF('POISSON', K, 5);
5
OUTPUT;
6
END;
7
RUN;
4 Code Block
DATA STEP Data
Explanation : Simulation of unit data (JES.Units) with random serial numbers and installation dates via RANUNI.
Copied!
DATA JES.Units; FORMAT SN $4. Install MMDDYY10.;
SEED=12345;
DO I=1 TO 10;
CALL RANUNI(SEED, X); CALL RANUNI(SEED, Y); CALL RANUNI(SEED, Z);
SN=put(FLOOR(99*X), Z4.0);
Install = '01JUN2006'd + ROUND(21*Y);
Loc ="CA"; IF Z<.45 THEN Loc="NY";
OUTPUT;
END;
DROP i X Y Z SEED;
RUN;
Explanation : Modification of JES.Units to introduce duplicates or shifted values using the LAG3 function on the serial number.
Copied!
DATA JES.Units; SET JES.Units;
L=LAG3(SN);
IF _N_ in (4,6,8) THEN SN=L;
DROP L;
RUN;
1
DATA JES.Units; SET JES.Units;
2
L=LAG3(SN);
3
IF _N_ in (4,6,8) THEN SN=L;
4
DROP L;
5
RUN;
6 Code Block
DATA STEP Data
Explanation : Simulation of failure data (JES.Fails) with random dates and locations.
Copied!
DATA JES.Fails; FORMAT SN $4. Fail MMDDYY10. Loc $6.;
SEED=12345;
DO I=1 TO 10;
CALL RANUNI(SEED, X); CALL RANUNI(SEED, Y); CALL RANUNI(SEED, Z);
SN=put(FLOOR(99*X), Z4.0);
Fail = '01JUL2006'd + FLOOR(90*Y);
Loc ="Top"; IF Z<.45 THEN Loc="Bottom";
OUTPUT;
END;
DROP i X Y Z SEED;
RUN;
1
DATA JES.Fails; FORMAT SN $4. Fail MMDDYY10. Loc $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;
9
RUN;
10 Code Block
DATA STEP Data
Explanation : Final calculation of the failure rate (Rate) in the JES.Rates table.
Copied!
DATA JES.Rates; set JES.Rates; Format Rate percent8.2;
if Test>0 then Rate=Fail/Test;
drop SEED i;
RUN;
1
DATA JES.Rates; SET JES.Rates; FORMAT Rate percent8.2;
2
IF Test>0 THEN Rate=Fail/Test;
3
drop SEED i;
4
RUN;
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.