BookmarkSubscribeRSS Feed
kamur
Calcite | Level 5
Hello,
I am using mainframe SAS 9.1 and I would like understand the following INPUT statement especially the fields in paranthesis.

INPUT @39 (INT_CALC_TYPE1-INT_CALC_TYPE8) ($ 3. +169)
@42 (INT_CALC_CODE1-INT_CALC_CODE8) ($ 2. +170)
@57 (CURRENTRATE1-CURRENTRATE8) (PD5.6 +167)
@105 (INT_PAID_ITD1-INT_PAID_ITD8) (PD6.2 +166)
@111 (INT_ACCRUED_MTD1-INT_ACCRUED_MTD8)(PD8.6 +164)
@119 (INT_ACCRUED_YTD1-INT_ACCRUED_YTD8)(PD8.6 +164)
@127 (INT_ACCRUED_ITD1-INT_ACCRUED_ITD8)(PD8.6 +164)
@135 (ORIG_ACCR_TERM1-ORIG_ACCR_TERM8) (PD2. +170)
@137 (RMNG_ACCR_TERM1-RMNG_ACCR_TERM8) (PD2. +170)
@139 (ACCRUALSTRTDTE1-ACCRUALSTRTDTE8) (PD4. +168)
@143 (ACCRUALLASTDTE1-ACCRUALLASTDTE8) (PD4. +168)
@57 CURRENTRATE PD5.6
@105 INT_PAID_ITD PD6.2
@111 INT_ACCRUED_MTD PD8.6
@119 INT_ACCRUED_YTD PD8.6 @;


Take for example: I see the statements:
@57 (CURRENTRATE1-CURRENTRATE8) (PD5.6 +167)
and
@57 CURRENTRATE PD5.6

What does this mean? When I output this to a permanent dataset using PUT statement, how should I handle these?

Thanks
2 REPLIES 2
art297
Opal | Level 21
You asked a couple of questions. First, regarding the input statements, run the following code:


data have;
input @4 (x1-x3) ($1. +4)
@1 (y1-y3) ($1.);
cards;
abcdefghijklmnopqrstuvwxyz
;

You'll see that x1 x2 and x3 are input, beginning with the fourth column, then skipping 4 columns before reading x2, and another 4 columns before reading x3. All are read with the $1. informat.

Conversely, y1 to y3 take the values from columns 1 thru 3.

As for your second question, concentrate1 and concentrate are both reading the same values.

I'm not sure what you're asking in your third question. If you assign a library name to some directory, and define it as the library where the file resulting from the input should go (e.g.,
libname mylib "c:\";
data mylib.thisdata;
input etc etc.
run;

The permanent SAS file will already be saved.

HTH,
Art
Cynthia_sas
Diamond | Level 26
Hi:
I am confused by this statement:
"When I output this to a permanent dataset using PUT statement, how should I handle these?"

You would output observations to a permanent SAS dataset in 1 of 2 ways (since you did not show your whole program, there's no way to know which way you are using):
1) implicit output (where there is an implied OUTPUT for every iteration of the DATA step program)
2) explicit output with an OUTPUT statement

If you are using an OUTPUT statement (either implicit or explicit), then you would be creating a permanent SAS dataset.

If, on the other hand, you have a FILENAME statement and PUT statements, you would not be creating an permanent SAS dataset -- you would be creating a permanent file (usually sequential or ASCII text file), as defined with a DD statement or a filename statement. The INPUT statement generally reads data from a 'flat" or sequential file. The PUT statement generally writes data to a "flat" or sequential file. This "flat" file from a PUT statement would not be a permanent SAS dataset -- you would point to it with a FILENAME statement, not with a LIBNAME statement.

(And let's not forget that the rest of your program might use the PUT function to convert numeric variables to character variables.)

I also notice that your program has a single trailing @ character at the end of the INPUT statement. Generally this means that you are holding the INPUT line for another execution of the INPUT statement. Seeing more of your program, including other INPUT, PUT and OUTPUT statements might be useful.

For further reading, I recommend these:
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000146292.htm (the INPUT statement)
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000146292.htm (Using Line-Hold Specifiers)
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a002645780.htm
http://www2.sas.com/proceedings/sugi29/253-29.pdf

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1966 views
  • 0 likes
  • 3 in conversation