BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User
data food;
infile datalines truncover;
input @1 Restaurant $11.  @13 NumEmploy 1. @15 Location $20.;
datalines;
burger king 5 toronto
;
run;
PaigeMiller
Diamond | Level 26

Yes, if you are having trouble, please state a clear question and describe what is wrong.

--
Paige Miller
Tom
Super User Tom
Super User

@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
;

Tom_0-1681328353081.png

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 1726 views
  • 1 like
  • 4 in conversation