DATA Step, Macro, Functions and more

input with '@' informat

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

input with '@' informat

I found out the answer by creating the color.txt  file and submitting in the SAS Univ Edn. However,I couldn't figure out the reason for the answer.

 

The question is :

 

Given the text file COLORS.TXT:

----+----1----+----2----+----
RED    ORANGE  YELLOW  GREEN
BLUE   INDIGO  PURPLE  VIOLET
CYAN   WHITE   FUCSIA  BLACK
GRAY   BROWN   PINK    MAGENTA

The following SAS program is submitted:

data WORK.COLORS;
  infile 'COLORS.TXT';
  input @1 Var1 $ @8 Var2 $ @;
  input @1 Var3 $ @8 Var4 $ @;
run;

What will the data set WORK.COLORS contain?

 

 

options are:

 

 

  1. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   RED     ORANGE
    BLUE     INDIGO   BLUE    INDIGO
    CYAN     WHITE    CYAN    WHITE
    GRAY     BROWN    GRAY    BROWN
  2. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   BLUE    INDIGO
    CYAN     WHITE    GRAY    BROWN
  3. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   YELLOW  GREEN
    BLUE     INDIGO   PURPLE  VIOLET
  4. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   YELLOW  GREEN
    BLUE     INDIGO   PURPLE  VIOLET
    CYAN     WHITE    FUCSIA  BLACK
    GRAY     BROWN    PINK    MAGENTA

 

 


Accepted Solutions
Solution
‎05-08-2017 12:03 AM
Super User
Posts: 19,770

Re: input with '@' informat

Posted in reply to Sathiskumar_D

 

RTM. What does the documentation say regarding the trailing @?

 

@

holds an input record for the execution of the next INPUT statement within the same iteration of the DATA step. This line-hold specifier is called trailing @.

Restriction The trailing @ must be the last item in the INPUT statement.
Tip The trailing @ prevents the next INPUT statement from automatically releasing the current input record and reading the next record into the input buffer. It is useful when you need to read from a record multiple times.
See Using Line-Hold Specifiers
Holding a Record in the Input Buffer

 

 

View solution in original post


All Replies
Occasional Contributor
Posts: 12

Logic for getting this answer

Posted in reply to Sathiskumar_D

I found out the answer by creating the color.txt  file and submitting in the SAS Univ Edn. However,I couldn't figure out the reason for the answer.

 

The question is :

 

Given the text file COLORS.TXT:

----+----1----+----2----+----
RED    ORANGE  YELLOW  GREEN
BLUE   INDIGO  PURPLE  VIOLET
CYAN   WHITE   FUCSIA  BLACK
GRAY   BROWN   PINK    MAGENTA

The following SAS program is submitted:

data WORK.COLORS;
  infile 'COLORS.TXT';
  input @1 Var1 $ @8 Var2 $ @;
  input @1 Var3 $ @8 Var4 $ @;
run;

What will the data set WORK.COLORS contain?

 

 

options are:

 

 

  1. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   RED     ORANGE
    BLUE     INDIGO   BLUE    INDIGO
    CYAN     WHITE    CYAN    WHITE
    GRAY     BROWN    GRAY    BROWN
  2. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   BLUE    INDIGO
    CYAN     WHITE    GRAY    BROWN
  3. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   YELLOW  GREEN
    BLUE     INDIGO   PURPLE  VIOLET
  4. Var1     Var2     Var3    Var4
    ------   ------   ------  ------
    RED      ORANGE   YELLOW  GREEN
    BLUE     INDIGO   PURPLE  VIOLET
    CYAN     WHITE    FUCSIA  BLACK
    GRAY     BROWN    PINK    MAGENTA

 

 

Super User
Posts: 19,770

Re: Logic for getting this answer

Posted in reply to Sathiskumar_D

@Sathiskumar_D Please do not post the same question multiple times. It will not increase the number of responses and isn't helpful. 

Occasional Contributor
Posts: 12

Re: Logic for getting this answer

When I posted the question first time, it didn't aacept the question.I am not aware of the fact that my previous question was posted.My apologies.

Solution
‎05-08-2017 12:03 AM
Super User
Posts: 19,770

Re: input with '@' informat

Posted in reply to Sathiskumar_D

 

RTM. What does the documentation say regarding the trailing @?

 

@

holds an input record for the execution of the next INPUT statement within the same iteration of the DATA step. This line-hold specifier is called trailing @.

Restriction The trailing @ must be the last item in the INPUT statement.
Tip The trailing @ prevents the next INPUT statement from automatically releasing the current input record and reading the next record into the input buffer. It is useful when you need to read from a record multiple times.
See Using Line-Hold Specifiers
Holding a Record in the Input Buffer

 

 

Occasional Contributor
Posts: 12

Re: input with '@' informat

SAS prep Guide says that '@' or '@@' cannot be used with @pointer control, with column input, nor with the MISSOVER option.In my question, however, there is '@'pointer control.

Super User
Posts: 19,770

Re: input with '@' informat

Posted in reply to Sathiskumar_D

Either it's incorrect or you're misunderstanding the text.

What's the page reference for this, I'm assuming SAS Base Certification Prep guide, what version? 

 

http://support.sas.com/publishing/cert/basecertguide3.html 

 

 

Occasional Contributor
Posts: 12

Re: input with '@' informat

It is Third Edition (Page # 608 and Chapter 20).They had provided an example where '@' pointer control was NOT used.However, the caveat, that was mentioned, is for double trailing '@@'.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 237 views
  • 0 likes
  • 2 in conversation