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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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