Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


1 new york 7,262,700
2 los angeles 3,259,340
3 philadelphia 1,642,900

how to read the above data using input statement
consider the above data is in txt format externally
u have to use infile and input statement.

Answers were Sorted based on User's Feedback



1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / subbu

data s;
input no 1-2 area $ 3-15 am $ 16-30 ;
amount=input(am,comma15.);
format amount comma15.;
drop am;
cards;
1 new york 7,262,700
2 los angeles 3,259,340
3 philadelphia 1,642,900
;
proc print;
run;

Is This Answer Correct ?    4 Yes 0 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / amy

Add a colon modifier before the informat (commaw.) and increase the informat width, like the following.

data cityrank;
infile 'D:\miths data\Mithelesh\cityrank.txt' ;
input rank city $12. amount : comma15.;
run;
proc print data=cityrank;
run;

Is This Answer Correct ?    6 Yes 5 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / pravin

data cityrank;

input rank @3 city $ 13. amount : comma15.;
datalines;
1 new york 7,262,700
2 los angeles 3,259,340
3 philadelphia 1,642,900

;
run;
proc print data=cityrank;
run;

this is the ans only for this example new york has more than
single blank so problem arise hire.if not & modifier can be
used.

Is This Answer Correct ?    3 Yes 3 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / ravikumar

Answer:

data cityrank;
input rank 1-2 @3 city $13. @16 amoutnt comma15.;
datalines;
1 new york 7,262,700
2 los angeles 3,259,340
3 philadelphia 1,642,900
;
run;

Is This Answer Correct ?    2 Yes 4 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / chandrakanth

To Solasa and others ....whenever you read data from an input file...you need to be careful about the last data value in every dataline you have values like x,xxx,xxx which is total width of 9, when you mention more than 9 the input pointer will go the next data line to get the remaining spaces. So in your code you used comma10. try with using comma9. I am very sure it will work.

Another option is if you want to keep that comma10. use TRUNCOVER in the infile statement, this should fix all the extra spaces you mention in the input statement.

let me know if this does not help you

Is This Answer Correct ?    0 Yes 2 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / poornima

data poo;
infile 'D:\poo.txt ';
input rank country $ 12. salary ;
INFORMAT SALARY COMMA10.;
FORMAT SALARY COMMA10.;
run;

proc print;
run;

Is This Answer Correct ?    0 Yes 2 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / guest

data temp;
infile datalines ;
input sno city & $12.
pop : comma.;
datalines;
1 new york 7,262,700
2 los angeles 3,259,340
3 philadelphia 1,642,900
;

The ampersand (&) modifier is used to read character values
that contain embedded blanks.
The colon (:) modifier is used to read nonstandard data
values and character values that are longer than eight
characters, but which contain no embedded blanks.

Is This Answer Correct ?    0 Yes 3 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / guest

data temp;
infile datalines ;
input sno city & $12.
pop : comma.;
datalines;
1 new york 7,262,700
2 los angeles 3,259,340
3 philadelphia 1,642,900
;

The ampersand (&) modifier is used to read character values
that contain embedded blanks.
The colon (:) modifier is used to read nonstandard data
values and character values that are longer than eight
characters, but which contain no embedded blanks.

Is This Answer Correct ?    1 Yes 4 No

1 new york 7,262,700 2 los angeles 3,259,340 3 philadelphia 1,642,900 how to read ..

Answer / solasa

data cityrank;
infile 'D:\miths data\Mithelesh\cityrank.txt' ;
input rank city & $12. amoutnt comma10.;
run;
proc print data=cityrank;
run;

problem with amount varible
tell what to do?

Is This Answer Correct ?    3 Yes 12 No

Post New Answer

More SAS Interview Questions

what is SAS ACCESS AND SAS CONNECT ? Give an example and data statements used.

1 Answers   TCS,


what is operational data and operational system? : Sas-di

0 Answers  


how do you pull data from equifax?tell me the process?

0 Answers   Synchrony Financial,


how can you improve the performance of a query, If it is excuting very slowly?

2 Answers   Zensar,


Hi... this is chandu, did MSc Microbiology, trying to get job in SAS tool, PLZ Tell me whether IT industries will give consider my education to gain a job....?

2 Answers  


For a user to have access to a standard workspace server, is internal authentication alone is sufficient? : sas-grid-administration

0 Answers  


Describe the function and untility of the most difficult SAS macro that you have written.

0 Answers  


I have a dataset concat having variable a b & c. How to rename a b to e & f?

0 Answers  


What do you feel about hardcoding?

1 Answers  


sas implementing companies in pune implementing clinical projects if anyone knows plz send ans immediately

0 Answers  


If you?re not wanting any SAS output from a data step, how would you code the data statement to prevent SAS from producing a set?

1 Answers  


If you need the value of a variable rather than the variable itself what would you use to load the value to a macro variable? : sas-macro

0 Answers  


Categories