put statement

Reply
Contributor
Posts: 51

put statement

Hi all,

Could you help me with put statement? Thank you so much,

I can not copy the whole code because it is too long. I only show the part that I met the error only.

code:

put "INFILE "D:\aging\data\2005\tab4\sumfile\prod\data\us00000001m.2005-1yr.txt" DSD TRUNCOVER DELIMITER =',' LRECL=3000;";

Errors:

4999  +INFILE

4999 !+D:\Aging\data\2005\tab4\sumfile\prod\data\us0000001m.2005

        -

        23

ERROR 23-2: Invalid option name :.

4999 !+D:\Aging\data\2005\tab4\sumfile\prod\data\us0000001m.2005

          -----

          23

ERROR 23-2: Invalid option name AGING.

4999 !+D:\Aging\data\2005\tab4\sumfile\prod\data\us0000001m.2005

                ----                        ----

                23                          23

ERROR 23-2: Invalid option name DATA.

4999 !+D:\Aging\data\2005\tab4\sumfile\prod\data\us0000001m.2005

                          ----

                          23

ERROR 23-2: Invalid option name TAB4.

4999 !+D:\Aging\data\2005\tab4\sumfile\prod\data\us0000001m.2005

                               -------

                               23

ERROR 23-2: Invalid option name SUMFILE.

4999 !+D:\Aging\data\2005\tab4\sumfile\prod\data\us0000001m.2005

                                       ----

                                       23

4999 !+-1yr.txt DSD TRUNCOVER DELIMITER =',' LRECL=3000;

ERROR 23-2: Invalid option name PROD.

NOTE: The SAS System stopped processing this step because of

      errors.

Super User
Posts: 11,343

Re: put statement

Are you trying to write output to "D:\aging\data\2005\tab4\sumfile\prod\data\us00000001m.2005-1yr.txt"?

If so, then the you have a separate FILE statement with the file name and options. PUT statements would only have the varaibles or literal text you want written into the file.

file "D:\aging\data\2005\tab4\sumfile\prod\data\us00000001m.2005-1yr.txt" DSD TRUNCOVER DELIMITER =',' LRECL=3000;

put vars

If you are trying to write the displayed text to a file then you need to work about where your quotes go. The first error message is because

put "infile "D:\ <etc>

says in more human terms: Write the string infile and then tries to interpret D:\ as either a variable or a put option such as column/line control. Since it is none of those then message about unrecognized options.

The rest of the line behaves similarily.

To put that string you need to watch the quotes much more carefully and know that to output a quote within a quoted string you use double quotes:

put "INFILE ""D:\aging\data\2005\tab4\sumfile\prod\data\us00000001m.2005-1yr.txt"" DSD TRUNCOVER DELIMITER =',' LRECL=3000;";

Ask a Question
Discussion stats
  • 1 reply
  • 719 views
  • 0 likes
  • 2 in conversation