how can i get the date while i using named input format??

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

how can i get the date while i using named input format??

how can i get the date while i using named input format??

data d;

input id= name=$20. dob=ddmmyy10. sal= desig=$20.;

format dob ddmmyy10.;

cards;

desig=Assistant manager id=100 name=krishna chandran sal=5000 dob=21/09/1989

id=101 dob=10/05/2010 desig=engineer sal=8000 name=hareesh Menon

run;

while i run this code i couldn't view the date in table.Any one can suggest some tips for fixing the problem as soon as possible


Accepted Solutions
Solution
‎07-11-2014 02:26 AM
N/A
Posts: 1

Re: how can i get the date while i using named input format??

Hope this would help you.

I could do it in two steps...

data d;

input id= name=$20. dob=$10. sal= desig=$20.;

cards;

desig=Assistant manager id=100 name=krishna chandran sal=5000 dob=21/09/1989

id=101 dob=10/05/2010 desig=engineer sal=8000 name=hareesh Menon

quit;

data r;

  set d;

  dob_ = input(dob,ddmmyy10.);

  format dob_ ddmmyy10.;

  drop dob;

  rename dob_ = dob;

run;

Try this..

Lakshmi.

View solution in original post


All Replies
Solution
‎07-11-2014 02:26 AM
N/A
Posts: 1

Re: how can i get the date while i using named input format??

Hope this would help you.

I could do it in two steps...

data d;

input id= name=$20. dob=$10. sal= desig=$20.;

cards;

desig=Assistant manager id=100 name=krishna chandran sal=5000 dob=21/09/1989

id=101 dob=10/05/2010 desig=engineer sal=8000 name=hareesh Menon

quit;

data r;

  set d;

  dob_ = input(dob,ddmmyy10.);

  format dob_ ddmmyy10.;

  drop dob;

  rename dob_ = dob;

run;

Try this..

Lakshmi.

Frequent Contributor
Posts: 89

Re: how can i get the date while i using named input format??

Hai Lekshmi i got the output with your code..Thanks for your valuable reply

Krishna

Super User
Super User
Posts: 7,392

Re: how can i get the date while i using named input format??

Hi,

Well, I have never seen that type of cards statement use before.  Unusual.  Personally I would agree with Chrishi, one step approach.  Firstly define what you want your output dataset to look like - the attrib statements - then have an infile statement to define delimiter (because if you have more than 10 rows of data you don't want to be typing variable names each time - unless you like typing?).  Then input the data.  This approach would also work entering data into Excel for instance and then importing, just change the infile from cards to a filename.

Frequent Contributor
Posts: 89

Re: how can i get the date while i using named input format??

Thanks RW9 for your valuable information.Am beginner in SAS Technology.I need to learn more from sas

Reagrds

Krishna

Super User
Super User
Posts: 7,392

Re: how can i get the date while i using named input format??

No probs.  I forgot to actually include the code on my post:

data d;

  attrib  id format=$20.

          name format=$20.

          dob format=ddmmyy10. informat=ddmmyy10.

          sal format=best.

          desig format=$20.;

  infile cards delimiter=',';

  input id name $ dob sal desig $;

cards;

100,krishna chandran,21/09/1989,5000,assistant manager

101,hareesh menon,10/05/2010,8000,engineer

run;

Frequent Contributor
Posts: 89

Re: how can i get the date while i using named input format??

Thanks i got it Smiley Happy

Contributor
Posts: 29

Re: how can i get the date while i using named input format??

Hi

you have to give informat before the input line for dob that will resolve your problem i hope.

data d;

informat dob ddmmyy10.;

input id= name=$20. dob= sal= desig=$20.;

format dob ddmmyy10.;

cards;

desig=Assistant manager id=100 name=krishna chandran sal=5000 dob=21/09/1989

id=101 dob=10/05/2010 desig=engineer sal=8000 name=hareesh Menon

run;

Thanks,

Sudeer.

Frequent Contributor
Posts: 89

Re: how can i get the date while i using named input format??

Thanks Sudeer.

while i using with your code.The table shown the 3rd observations as filled with period(.)

I also need to get the columns in proper order..How could it possible Sudeer?

Regards

Krishna

Respected Advisor
Posts: 3,777

Re: how can i get the date while i using named input format??

Named input can be useful.  I would write it like this to define the variables, provide INFORMATS and FORMATS as needed, and get them in the order you desire.  Plus it makes you look like you know what you're doing. Smiley Happy

data namedinput;
   attrib id    length=8;
  
attrib name  length=$20;
  
attrib dob   length=8 informat=ddmmyy10. format=ddmmyyd10.;
  
attrib sal   length=8;
  
attrib desig length=$20;
  
infile cards;
  
input (_all_)(=); 
  
cards;
desig=Assistant manager id=100 name=krishna chandran sal=5000 dob=21/09/1989
id=101 dob=10/05/2010 desig=engineer sal=8000 name=hareesh Menon
run;
Frequent Contributor
Posts: 89

Re: how can i get the date while i using named input format??

thanks i got it Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 472 views
  • 9 likes
  • 5 in conversation