Prepares raw data received from Socialstyrelsen (national patient registry or cause of death registry) to be processed by function make_sosvar. Removes post with missing information on relevant dates and joins diagnosis columns together. Reason for preparation is to save space in internal memory (by joining columns together) and removing surplus columns.
Data from Socialstyrelsen that should be prepared. Should contain at least HDIA, OP, ekod, INDATUM
What registry is being prepared? Takes values patreg (National patient registry) or dors (Cause of death registry). Default is National patient registry.
Should the sosdtm (usually to be used in comparison with indexdate) be date of discharge for hospitalisation? Default is FALSE. Else date of admission is used.
Should the individual DIA (except HDIA), OP, ekod variables be removed after constructing combined variable (to save space)? Default is TRUE.
If patreg = "dors" imputes missing month and date in DODSDAT. Possibly to be implemented in patreg. kom ihåg att kolla om finns värden i INDATUMA (text) men inte i INDATUM (numerisk). i så fall imputera.
The starting characters of variables containing diagnosis (used if registry = patreg).
The starting characters of variables containing operations (used if registry = patreg).
The starting characters of variables containing ekod (used if registry = patreg).
The starting characters of variables containing causes of death (used if registry = dors).
The main variable that should be saved in the data even if remove = TRUE.
sosdataset with combined DIA, OP, ekod variables and space in front of HDIA and sosdtm.