BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
kinjal
Calcite | Level 5

data inventory;
retain id item price vendor;

input id item$ 11. price vendor$ 20.;
msrp=price*1.5;
label id ='Item Id' msrp='Max Retail price';
cards;
1 apple 2.19 walmart
2 grapes 1.99 shop$stop
;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
input id item : $11. price : best12. vendor : $20.;

View solution in original post

17 REPLIES 17
PaigeMiller
Diamond | Level 26

Normally when you are a having problems, you go ahead and describe the problems to us, and show us the ENTIRE log for this code. Otherwise how would we know what the error is that you are having?

--
Paige Miller
kinjal
Calcite | Level 5
getting dot as output in price and vendor variable.
kinjal
Calcite | Level 5
I am very new in sas programing need help
kinjal
Calcite | Level 5
getting dots as output in price and vendor variables
Reeza
Super User
input id item : $11. price : best12. vendor : $20.;
kinjal
Calcite | Level 5

Thank you 

kinjal
Calcite | Level 5
if you don't mind then please explain me : and best why we use here ??
Reeza
Super User
When you specify $11 without a modifier SAS reads 11 characters. With the modifier it reads until it encounters a space is the biggest reason.

Another way to achieve this is to specify informats not on the INPUT statement.
kinjal
Calcite | Level 5
data food;
input @1Restaurant$ 11.@12NumEmploy 1. @13Location$ 20.;
datalines;

burger king 5 toronto;

run;
Reeza
Super User
Is that a question?
kinjal
Calcite | Level 5
Yes dear can you able to help me ??##- Please type your reply above this
line. No attachments. -##
Reeza
Super User

You cannot just post some random code, expect someone to run it, find the error and debug it for you.

 

Please frame your questions as follows if you want help efficiently. This will allow us to help you get your problems solved. 

In general, see this post  or this post on how to ask good programming questions. You'll save yourself a ton of time and get your answers much faster.

 

This is my problem (I am trying to read in data that has two parts to a name separated by a space into one variable but it's not working correctly)

What you'ved tried: This is my code so far

What happens with that code:

This is what it generates and this is the log. 

 

 

kinjal
Calcite | Level 5
Thank you. I will try better next time.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 3122 views
  • 1 like
  • 4 in conversation