@kinjal wrote:
if you don't mind then please explain me : and best why we use here ??
If you use an INFORMAT in the INPUT statement then SAS will use FORMATTED MODE input for that variable.
By adding the colon modifier you are telling the INPUT statement to use LIST MODE input for that variable instead.
You don't really need to include any special informats for any of your variables. The only advantage of using an INFORMAT for ITEM or VENDOR in the INPUT statement is if you have not previously told SAS what type of variables those are. If the first place that SAS sees the variable (at least the first place where the type of the variable is important, unlike in the RETAIN statement) is in an INPUT statement then SAS will use the width of the INFORMAT to make a GUESS about how you wanted the variable defined.
But the code will work better and be clearer if you just go ahead and DEFINE the variables before you use them in the INPUT statement. There is also no need to tell SAS that the variable values need to be retained across iterations of the data step.
data inventory;
length id 8 item $11 price 8 vendor $20 msrp 8;
input id item price vendor;
msrp=price*1.5;
label id ='Item Id' msrp='Max Retail price';
cards;
1 apple 2.19 walmart
2 grapes 1.99 shop$stop
;