Published on :
Data Preparation CREATION_INTERNE

Creation of Reference Data for Demonstration

This code is also available in: Deutsch Español Français
Awaiting validation
The main objective of this script is to provide a set of fictitious, self-contained data for demonstrations, tests, or analysis examples. It sequentially defines tables for:
  • 'person': basic demographic information of individuals.
  • 'indlag': details of hospital admissions.
  • 'syghus': hospital names corresponding to their identifiers.
  • 'priser': medical procedure rates with validity periods.
Each DATA STEP block is self-contained and creates a specific table with its appropriate variables and formats. The data is hardcoded via the DATALINES statement.
Data Analysis

Type : CREATION_INTERNE


All data used in this script is internally generated via the DATALINES statement. This means that no external data sources (flat files, databases, etc.) are required for execution. The created datasets are 'person', 'indlag', 'syghus', and 'priser', serving as complete input data for further processing.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the `person` table, which contains basic identity information for four individuals. The variables `CPR` (numeric identifier), `Navn` (textual name), and `By` (textual city) are defined with their respective types and lengths. Data is read via `datalines` with the `dsd` option to handle string delimiters (commas) and quotes.
Copied!
1DATA person;
2LENGTH CPR 8 Navn BY $20;
3INFILE DATALINES dsd;
4INPUT CPR Navn BY;
5DATALINES;
60102034567,"Anders","Allerød"
71012625678,"Barbara","Broby"
83111727892,"Charlotte","Charlottenlund"
91706582345,"Dennis","Dalby"
10;
11RUN;
2 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the `indlag` table, which records hospitalization details. It includes the variables `CPR`, `IndDT` (admission date and time, formatted as `datetime32.3`), `Sygh` (hospital identifier), and `Proc` (procedure code). The `datetime32.` informat is used to correctly read date and time values, while the `datetime32.3` format ensures precise display.
Copied!
1DATA indlag;
2LENGTH CPR IndDT Sygh 8 Proc $8;
3FORMAT IndDT datetime32.3;
4INFILE DATALINES dsd;
5INPUT CPR IndDT : datetime32. Sygh Proc;
6DATALINES;
70102034567, 01may2022:09:42:00, 123, "PP123"
81012625678, 13apr2022:07:33:00, 123, "PP234"
91012625678, 17apr2022:08:12:00, 123, "PP234"
103111727892, 05apr2022:13:00:00, 234, "PP123"
113111727892, 01may2022:08:00:00, 123, "PP123"
123111727892, 09may2022:09:37:00, 123, "PP235"
13;
14RUN;
3 Code Block
DATA STEP Data
Explanation :
This DATA STEP block generates the `syghus` table containing the list of hospitals. It associates a numeric hospital identifier (`Sygh`) with its textual name (`Tekst`). Data is directly embedded via `datalines`.
Copied!
1DATA syghus;
2LENGTH Sygh 8 Tekst $20;
3INFILE DATALINES dsd;
4INPUT Sygh tekst;
5DATALINES;
6123, "Holbæk"
7234, "Ringsted"
8345, "Næstved"
9RUN;
4 Code Block
DATA STEP Data
Explanation :
This DATA STEP block constructs the `priser` table, which defines medical procedure rates over different validity periods. The variables `Procedure` (procedure code), `FraDato` and `TilDato` (start and end dates of validity, formatted as `date9.`), and `Pris` (price, formatted as `Commax18.2`) are included. The `date9.` informats are used to read dates correctly.
Copied!
1DATA priser;
2LENGTH Procedure $8 FraDato TilDato Pris 8;
3FORMAT Fradato Tildato date9. Pris Commax18.2;
4INFILE DATALINES dsd;
5INPUT Procedure FraDato : date9. TilDato : date9. Pris;
6DATALINES;
7PP123, 01jan2022, 28feb2022, 900
8PP123, 01mar2022, 31dec9999, 1000
9PP234, 01jan2022, 28feb2022, 1100
10PP234, 01mar2022, 31mar2022, 1200
11PP234, 01apr2022, 31dec9999, 1500
12PP345, 01jan2022, 31dec9999, 3000
13;
14RUN;
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.