Nevertheless Published Mine

    xpt2json

    0.8.2 • Public • Published

    node-xpt2json

    NPM Stats
    Build Status npm npm downloads

    The SAS® Transport File Format (XPT) is an openly documented specification maintained by SAS®, The SAS® Version 5 (V5) transport file format is an open standard developed by SAS to support data transfers between systems, especially those running different operating systems. The V5 transport specification is nonproprietary.

    SAS Version 5 (V5)传输文件格式是由SAS开发的开放标准,用于支持系统之间的数据传输,特别是运行不同操作系统的系统之间的数据传输。

    SAS® has recently developed a new transport file format specification, along with three macros, that extends the older V5 transport file format and provides new capabilities. Hence The V5 and V8 transport file is widely used in the bio-pharmaceutical industries.

    V5传输规范是非专有的。SAS最近开发了一个新的传输文件格式规范,以及三个宏,扩展了旧的V5传输文件格式并提供了新的功能。因此,V5和V8传输文件被广泛应用于生物制药行业。

    Ever had the urge to parse XPT without SAS? And wanted to access the data in some sane, easy way? XPT file occupy too much memory in you computer and you want to compress it without any loss. Do you want to be able to display the data only through your browser? Don't want to rent a SAS licence, for whatever reason? Then xpt2json is what you're looking for!

    曾经有过在没有 SAS 的情况下解析 XPT 的冲动吗?并希望以一些合理、简单的方式来访问数据?XPT 文件在你的计算机中占据了太多的内存,你想在没有任何损失的情况下进行压缩。你想只通过你的浏览器就能显示数据?不管什么原因,不想租一个 SAS 许可证?那么 xpt2json 就是你要找的解决方案!

    Description

    Simple XPT to JavaScript object converter. I'm trying to make it support bidirectional conversion. So far, English writing has been implemented in the Node.js environment, and Chinese and browser-side will be coming soon.

    简单的 XPT 到 JavaScript 对象转换器。我努力使它支持双向转换。到目前为止, Node.js 环境下已经实现英文写入,中文及浏览器端不久之后也会实现.

    Installation

    Simplest way to install xpt2json is to use npm, just npm install xpt2json which will download xpt2json and all dependencies.

    安装 xpt2json 最简单的方法是使用 npm,只要 npm install xpt2json 就可以下载 xpt2json 和所有依赖项。

    xpt2json is also available via Bower, just bower install xml2js which will download xml2js and all dependencies.

    xpt2json 也可以通过 Bower 获得,只需用 bower 安装 xml2js 就可以下载 xml2js 和所有的依赖项。

    Basic Read in Browser

        <script src="./node_modules/xpt2json/dist/xpt2json.iife.js"></script>
        <script>
            function getFile() {
                
                let uploadFile = document.getElementById("upload_file_id");
                let reader = new FileReader();
                 reader.readAsBinaryString(uploadFile.files[0]);
                 reader.onload = (res) => {
                    let jsonFile = xpt2json.readXpt(res.target.result);
                    console.log(jsonFile);
                };
            }
        </script>

    Best Practice

    XPT Viewer

    Basic Read in Node

    const { readXpt } = require("./xpt2json");
    
    let strPathName = "./demo/dm_zh.xpt";
    let jsonData = readXpt(strPathName);
    // let jsonData = readXpt(strPathName,{encoding:'utf8'});
    console.log(jsonData);

    Basic Write in Node

    const { writeXpt } = require("./xpt2json");
    
    let strPathName = "./demo/dm.xpt";
    let jsonData = readXpt(strPathName);
    // let jsonData = readXpt(strPathName,{encoding:'utf8'});
    console.log(jsonData);
    /*Processing*/
    writeXpt("./demo/dm_test.xpt",jsonData)

    Data structrue of XPT objects

        XPT {
            VERSION:{
                type:string,
                value:"V5"|"V8"
            },
            ENCODING:{
                    type:string,
                    value:"ANSI"|"zeuc"|...
            },// Only for CPORT Result.
            LIBRARY:{
                type:object // data sorce information.
            },
            MEMBER:{
                type:object // dataset information, e.g. name, label
            },
            OBS:{           
                type:array // Observations infrmation by variale.
                value:[
                        {
                            "NTYPE": 2,                  /* VARIABLE TYPE: 1=NUMERIC, 2=CHAR */
                            "NHFUN": 0,                  /* HASH OF NNAME (always 0) */
                            "NLNG": 7,                   /* LENGTH OF VARIABLE IN OBSERVATION e.g. length("CDISC01")=7*/
                            "NVAR0": 1,                  /* VARIABLE ORDER */
                            "NNAME": "STUDYID",          /* NAME OF VARIABLE */
                            "NLABEL": "Study Identifier",/* LABEL OF VARIABLE */
                            "NFORM": null,               /* NAME OF FORMAT */
                            "NFL": 0,                    /* FORMAT FIELD LENGTH OR 0 */
                            "NFD": 0,                    /* FORMAT NUMBER OF DECIMALS */
                            "NFJ": 0,                    /* 0=LEFT JUSTIFICATION, 1=RIGHT JUST */
                            "NFILL": null,               /* (UNUSED, FOR ALIGNMENT AND FUTURE) */
                            "NIFORM": null,              /* NAME OF INPUT FORMAT */
                            "NIFL": 0,                   /* INFORMAT LENGTH ATTRIBUTE */
                            "NIFD": 0,                   /* INFORMAT NUMBER OF DECIMALS */
                            "NPOS": 0,                   /* POSITION OF VALUE IN OBSERVATION */
                            "REST": null,                /* remaining fields are irrelevant */
                            "RECORDS": [                 /* Observation */
                                        "CDISC01", 
                                        "CDISC01", 
                                        "CDISC01", 
                                        "CDISC01", 
                                        "CDISC01"
                                        ]
                        },
                        {
                            "NTYPE": 2,
                            "NHFUN": 0,
                            "NLNG": 4,
                            "NVAR0": 2,
                            "NNAME": "SEX",
                            "NLABEL": "性别",
                            "NFORM": null,
                            "NFL": 0,
                            "NFD": 0,
                            "NFJ": 0,
                            "NFILL": null,
                            "NIFORM": null,
                            "NIFL": 0,
                            "NIFD": 0,
                            "NPOS": 786432,
                            "REST": null,
                            "RECORDS": ["男", "女", "女", "女", "男"]
                        },
                        {
                            "NTYPE": 1,
                            "NHFUN": 0,
                            "NLNG": 8,
                            "NVAR0": 3,
                            "NNAME": "AGE",
                            "NLABEL": "年龄",
                            "NFORM": null,
                            "NFL": 0,
                            "NFD": 0,
                            "NFJ": 0,
                            "NFILL": null,
                            "NIFORM": null,
                            "NIFL": 0,
                            "NIFD": 0,
                            "NPOS": 1048576,
                            "REST": null,
                            "RECORDS": [14, 13, 13, 14, 14]
                        },
                        ...
                ]
            }
    }

    Huge XPT file

    Each dataset should be provided in a single transport file. The maximum size of an individual dataset that FDA can process depends on many factors. Datasets greater than 5 gigabytes (GB) in size should be split into smaller datasets no larger than 5 GB. STUDY DATA TECHNICAL CONFORMANCE GUIDE

    每个数据集应在一个单一的运输文件中提供。FDA可以处理的单个数据集的最大尺寸取决于许多因素。大于5GB的数据集应被分割成不大于5GB的小数据集。研究数据技术一致性指南
    const {readHugeXpt} = require("./`xpt2json`");
    readHugeXpt("./demo/dm.xpt", {}, (data) => {
        console.log(data);
    });

    Kindly Reminder

    There are two subtypes of SAS XPORT files in use, Version 5 and Version 8.For FDA,EMA and PMDA, you should select the V5, Both of V5 and V8 are accepted by NMPA.

    目前使用的SAS XPORT文件有两种子类型,即第5版和第8版.若递交于FDA,EMA 和 PMDA, 你应该选择V5格式,' V5 '和' V8 '都可以被NMPA接受。

    but SAS has two forms of transport file. described here is the publicly documented transport format produced by the XPORT engine and the COPY procedure (PROC COPY) or the LOC2XPT macro. xpt2json will return a object.

    但是SAS有两种形式的传输文件。这里描述的是由XPORT引擎和COPY过程(PROC COPY)或LOC2XPT宏生成的公开记录的传输格式。xpt2json 将返回一个对象。
        XPT {
            VERSION:{
                type:string,
                value:"V5"|"V8"
            },
            LIBRARY:{
                type:object // data sorce information
            },
            MEMBER:{
                type:object // dataset information, e.g. name, label
            },
        }

    A second form of transport file is produced by the CPORT procedure, which is intended only for transfer between SAS versions running compatible versions of the CPORT and CIMPORT procedures. SAS Transport files processed by the CPORT SAS PROC cannot be processed or archived by the FDA. xpt2json will return a array.

    第二种形式的传输文件由CPORT过程生成,它只用于运行CPORT和CIMPORT过程兼容版本的SAS版本之间的传输。由SAS PROC CPORT处理的传输文件不能被FDA处理或归档。xpt2json 将返回一个数组。
        [
            {
                ENCODING:{
                    type:string,
                    value:"ANSI"|"zeuc"|...
                },
                LIBRARY:{
                    type:object // data sorce information
                },
                MEMBER:{
                    type:object // dataset information, e.g. name, label
                },
            }
        ]
    }

    Getting support

    Please, if you have a problem with the library, please make sure your problem really is with xpt2json. It is? Okay, then I'll look at it. Send me a mail and we can talk.

    如果你的库有问题,请确定你的问题真的是出在xpt2json上。如果是的, 我一定会解决。请给我发个邮件,顺便我们可以聊聊。

    You are free to use this program to develop your system. However, please do not quote the object structure or derive this data structure for derivative structure development without the permission of the author, which has been submitted to the State Intellectual Property Office of the People's Republic of China.

    您可以自由应用此程序开发您的系统。但请勿在未经作者允许时引用对象结构或衍生此数据结构做衍生结构开发,此结构已递交中华人民共和国国家知识产权局。

    Author: Jianfeng YE (冶剑锋)
    Phone: +86 18710106985
    Mail: yejianfeng186@163.com
    linkin: www.linkedin.com/in/jianfeng-ye-63015b102

    Keywords

    SAS XPT JSON FDA EMA PMDA NMPA

    Install

    npm i xpt2json

    DownloadsWeekly Downloads

    34

    Version

    0.8.2

    License

    CC BY-NC-ND 4.0

    Unpacked Size

    468 kB

    Total Files

    22

    Last publish

    Collaborators

    • yejianfeng186