BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rvsidhu035
Quartz | Level 8

any errors kindly correct

 

input statement=>contains sequence of arguments
INPUT <variables> <informats> <record-directives> <positionals>;

varaible: char $ or & and numeric(default length=8)

informat: char=w. numeric=w.d  (w=width,d=decimal)

record-directives :to hold the current record so that
you can continue to read from the record with later
INPUT statements. Otherwise, IML automatically
goes to the next record for the next INPUT statement

positionals: go to a specific column on the record
@ operand ;to go to the indicated column
For example, @30 means to go to column 30
+ operand specifies to skip the indicated number of columns.;;

data;

input ========>   cards ==============> conditions ====================> output

compilation
1. syntax errors
2 pdv class
3 a b c
4 c n n
5 8 8 8
6 _ . .
Execution Phae :
pdv output
a b c a b c
_ . .
1 2 3 1 2 3
_ . .
4 5 6 4 5 6
_ . .
7 8 9 7 8 9

4 th

;

data class;
input a b ;
datalines ; /*cards*/
1 2 3
4
5 6 flowover
7 8 9
;
run;
input ========>   cards ==============>
conditions ====================> output
pdv output
a b a b
. .
1 2 1 2
. .
4 5 4 5
. .
7 8         7 8
. .

;

data;
INPUT <specification(s)><@|@@>;  

The INPUT statement with no arguments
is called a null INPUT statement.
The null INPUT statement;

data _null_;
set sashelp.class;
run;

specifications:

variable:
data var;
input var1 var2 $;
datalines;
1 rajesh
2 satheesh
;
run;

variable list;

data var_list;
input var1-var3 ;
datalines;
1 2 3
3 4 5
;
run;


pointer control:
(moves the input pointer to a specified line or column);
data point_ctr;
input @3 a @5 b;
datalines;
1 23456
6 54321
;
run;

column-specifications:
specifies the columns of the input record that contain
the value to read. ;
data clm_spc;
input a 1-3 b 5-6;
datalines;
123 45678
6547 2536
;
run;

format-modifier :
allows modified list input or controls the amount of
information that is reported in
the SAS log when an error in an input value occurs. ;

data format_md;
/*input a  b  ;*/
input a dollar4. b  comma7.;
format a dollar5. b comma7.;
datalines;
$250 1,200
$356 21,345
;
run;

informat.
specifies an informat to use to read the variable value.;
data informat_md;
/*input a  b  ;*/
input a dollar4. b  comma7.;
format a dollar5. b comma7.;
datalines;
$250 1,200
$356 21,345
;
run;

@
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  ;
data at_rate;
input a b @;
if b=2 then do;
input @5 c 1. @7 d 1.;end;
else if b=3 then delete;

datalines;
1 2 3 6 5
0 3 5 6  
0 3 2 6  
1 2 3 5 5
;
run;
data at_rate1;
input a b @ ;
/*if remove @ then chek reult*/
input  c  d ;
datalines;
1 2 3 6 5
0 3 5 6  
0 3 2 6  
1 2 3 5 5
;
run;




@@
holds the input record for the execution of the
next INPUT statement across iterations of the DATA step.
This line-hold specifier is called double trailing @. ;
data at_at_rate;
input a b c @@;
datalines;
1 2 3 4 5 6 7 8 9
;
run;

Column Pointer Controls :
@n
moves the pointer to column n.
ex: @15 moves the pointer to column 15: ;
data cp_control;
/*input @1 a $ @2 b$ @3 c;*/
input @1 a 1. @2  b $1. @3 c ;
datalines;
1M3
2F4
4F3
;
run;


@numeric-variable:
moves the pointer to
the column given by the value of numeric-variable.;
data numer_var(drop= d e f);
d=1;e=2;f=3;
input @d a 1. @e  b $1. @f c ;
datalines;
1M3
2F4
4F3
;
run;
@(expression)
moves the pointer to
the column that is given by the value of expression.


@'character-string' :
locates the specified series of characters in the input
record and moves the pointer to the first column after
character-string.
;
data at_cst;
input @'ravi' name $4. @'5' b $3.;
datalines;
kinravikijg 345369
ksravilkkj 25623
;
run;

@character-variable :
locates the series of characters in the input record
that is given by the value of character-variable and moves the pointer to
the first column after that series of characters.

data at_cst_var;
a='ravi';
input @a name $4. @'5' b $3.;
datalines;
kinravikijg 345369
ksravilkkj 25623
;
run;

@(character-expression)/@'character-string':
locates the series of characters in the input record
that is given by the value of character-expression and
moves the pointer to the first column after the series.


+n :
moves the pointer n columns;
data nplus;
/*input  a  +2 b +3  c;*/
input  a  +1 b +2  c;
datalines;
1  2345   6789
98 7465   231
;
run;


+numeric-variable :
moves the pointer the number of columns
that is given by the value of numeric-variable.

+(expression)
moves the pointer the number of columns given
by expression

Line Pointer Controls:

#n:
moves the pointer to record n

data at_the_rate6;
input #1 a b c #2 d e f;
datalines;
1 2 3
4 5 6
7 8 9
10 11 12
;
run;
data at_the_rate5;
input a b c;
input d e f;
datalines;
1 2 3
4 5 6
7 8 9
10 11 12
;
run;

/*One input statement, one semicolon, and*/
/*END; forward slash pointers:*/

data at_the_rate5;
input a b c/d e f;
datalines;
1 2 3
4 5 6
7 8 9
10 11 12
;
run;

#numeric-variable :
moves the pointer to the record that is
given by the value of numeric-variable.

#(expression):
moves the pointer to the record
that is given by the value of expression.

modifers : & and colon :
Ampersand (&) Modifier : It controls the SAS system,
values are separated by more than one space. When we use the ampersand format modifier,
two blanks are required to signal the end of a data value. It can effectively deal with embedded
spaces/blanks.We can also control length of the variable.

It recognizes
One single blank --> Embedded blank
More than one blank --> Delimiter blank

Colon(:) Modifier : It controls the length of the variable and call the informat techniques.

data modifiers ;
infile cards;
input eid name  &  $ 19. Des & $ 18. ;
cards;
101 Kiran Kumar varma  Tester
102 Swati Vohra  Finance Analyst
103 Kranthi Bommasani  Programmer

;
run;


"    The ~ (tilde) format modifier ; enables you to read and retain
single quotation marks, double quotation marks, and delimiters within
character values.";
"    The : (colon) format modifier enables you to use list input but also
to specify an informat after a variable name, whether character or numeric.
SAS reads until it encounters a blank column, the defined length of the variable
(character only), or the end of the data line, whichever comes first.";

data scores;
   infile datalines dlm="," dsd;
   input Name : $9. Score1-Score3 Team ~ $25. Div $;
   datalines;
Smith,12,22,46,"Green Hornets, Atlanta",AAA
Mitchel,23,19,25,"High Volts, Portland",AAA
Jones,09,17,54,"Vulcans, Las Vegas",AA
;
run;



input styles;depending on the arragement of data values;

1. column 2. list(simple and modified)
3.formatted 4.named(can not used another input style here)

1.column input:column numbers follow the variale name
   input name $ 1-8 age 11-12;
 data clm_ip;
 input name $ 1-8 age 11-12;
 datalines;
raviraje  27
kingmake  18
 ;
   run;

2.list input;variable names are simple listed
"data values are separated by balnk at least one"
ex; input name $ age;
data lst_ip;
input name $ age;
datalines;
raviraje 27
kingmake 18
;
run;

3.formatted input;apply both format and informat
format=sas data to human understand data display =read standard data
infomrat=read non standard data
ex; input name $char8. +2 income comma6.;
data form_ip;
input name $char8. +2 income comma6.;
/*format income comma6.;*/
datalines;
raju      12,000
sati      15,000
;
run;

4.named input;specify the name of the variable followed by an equal sign
ex;input name=$ age=;
data nm_ip;
input name=$ age=;
datalines;
name=rajesh age=25
name=shalini age=5
;
run;
5.multiple stysle in single input statement;expect named input
all of the different input styles
ex; input id name $18. team 25-30 startwght endwght;
data mul_ip;
input id  name $5-12 gender $1.;
datalines;
123  ravi   M
124  raju   M
125  shaliniF
;
run;

pointer controls;
column pointer controls; +n  @n
line pointer controls ; #n  /
line-hold specifiers;  @  @@

¢    column pointers;
 data noraml98;
input @1 a @3 b$ @5 c;
datalines;
1 M 3
2   4
  F 3
;
run;
¢    column skip pointer +n;
  data noraml36;
input  a +2  b$ +3 c;
datalines;
1   M    3
2   F    6
run;
data method4;
input empid 4. +4  name $ 18. +3 Des $ 10. ;
cards;
1001    Kiran kumar          Tester
1002    Kranti kumar panda   Analyst
1003    pawan kumar saha     Programmer
1004    Laxmikant Parida     Manager
;
run;
¢    column hold pointer @n
¢    column range pointer .n;
  data noraml;
input  a 1-3  b $5-10  c 11-16;
datalines;
123 raviol 34566
263 rajesh 36985
;
run;

5) absolute input method:

column hold pointer @n @4;

data method4;
input @1 empid 4. @9  name $ 18. @30 Des $ 10. ;
cards;
1001    Kiran kumar          Tester
1002    Kranti kumar panda   Analyst
1003    pawan kumar saha     Programmer
1004    Laxmikant Parida     Manager
;
run;





Format Modifiers for Error Reporting:

? :
suppresses printing the invalid data note
when SAS encounters invalid data values

?? :
suppresses printing the messages and the input lines
when SAS encounters invalid data values.
The automatic variable _ERROR_
is not set to 1 for the invalid observation.





1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

If your goal is to make a "cheat sheet" or tip sheet reference for the INPUT statement, I suggest:

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is the actual question here.  You have posted a full wall of text, a load of code, attached files, and yet I cannot find a single question anywhere?

rvsidhu035
Quartz | Level 8
Just info not a question
ChrisHemedinger
Community Manager

If your goal is to make a "cheat sheet" or tip sheet reference for the INPUT statement, I suggest:

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
rvsidhu035
Quartz | Level 8
Sorry, I am not make cheatsheet , my intention is to explore knowledge what you know or what I know . If I am not compete to Oskar , may this way of posting is wrong but some kids they learn base SAS face more difficult may usefully for this posting and also unclear matter in SAS document , take much more time to understand rules and conditions in SAS .so it's some how usefully if your ienstein in SAS just skip this post and I apologise to you regards your concern what you think."we are learner " we are learners ".thank your complement we recreate my mistake not to repate further.
rvsidhu035
Quartz | Level 8
Regrate= recreate dictionary fault

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
  • 5 replies
  • 1569 views
  • 5 likes
  • 3 in conversation