Home Forums Main Forums SAS Forum Use NULL INPUT to copy a file

  • Use NULL INPUT to copy a file

     Datura updated 3 years, 9 months ago 1 Member · 1 Post
  • Datura

    Member
    February 2, 2021 at 7:28 pm

    The below codes use a NULL INPUT, i.e. INPUT with no arguments, to copy records from the input file to the output file without creating any SAS variables. This is a cool trick in our daily work.

    data _null_;
    infile "file path\iron.txt";
    file "file path\test.txt";
    input;
    put _infile_;
    run;

    It is exactly a copying work.

    *Note:
    _infile_ = variable can specify a CHARACTER variable that references the contents of the current input buffer for the INFILE statement, such as:

     Data B;
    Infile cards _infile_= D;
    Input A B C;
    X=D;
    Cards;
    1 2 3
    4 5 6
    7 8 9
    ;
    run;

    Output:

    A B C X

    1 2 3 1 2 3

    4 5 6 4 5 6

    7 8 9 7 8 9

    Note: D and X are character variables, the designated size for D is 32,767 during compile time. We can NOT use Put _all_ here, which will output all the info in PDV as follows, rather than the original raw data.

    Put _all_ output:
    _ERROR_=0 _N_=1
    _ERROR_=0 _N_=2
    _ERROR_=0 _N_=3
    _ERROR_=0 _N_=4
    _ERROR_=0 _N_=5
    _ERROR_=0 _N_=6
    _ERROR_=0 _N_=7
    _ERROR_=0 _N_=8
    _ERROR_=0 _N_=9
    _ERROR_=0 _N_=10
    _ERROR_=0 _N_=11
    _ERROR_=0 _N_=12
    _ERROR_=0 _N_=13
    _ERROR_=0 _N_=14
    _ERROR_=0 _N_=15
    _ERROR_=0 _N_=16
    _ERROR_=0 _N_=17
    _ERROR_=0 _N_=18
    _ERROR_=0 _N_=19

Log in to reply.

Original Post
0 of 0 posts June 2018
Now