View previous topic :: View next topic |
Author |
Message |
sub Beginner
Joined: 30 Jan 2007 Posts: 20 Topics: 12
|
Posted: Wed Jun 08, 2011 7:51 pm Post subject: Create report using SAS |
|
|
Hi,
Can someone please help me with a solution for creating a report from the below input file using SAS. My input file looks like this
Code: |
STATE: New YORK
CITY : BUFFALO
DATE : 2011-01-01
STATE: NEW YORK
CITY : ALBANY
DATE : 2011-02-01
STATE: CALIFORNIA
CITY : MONTCLAIR
DATE : 2011-02-01
.
.
. |
I need the output to be generated as given below Code: |
STATE CITY DATE
New YORK BUFFALO 2011-01-01
NEW YORK ALBANY 2011-02-01
CALIFORNIA MONTCLAIR 2011-02-01
.
.
. |
Can it be done using SAS? |
|
Back to top |
|
|
chandra Beginner
Joined: 26 Sep 2003 Posts: 130 Topics: 36
|
Posted: Thu Jun 09, 2011 2:49 am Post subject: |
|
|
Hi Sub,
You can do it is SAS as follows.
Code: |
//OUTDD DD SYSOUT=*
//INDD DD *
New YORK
BUFFALO
2011-01-01
NEW YORK
ALBANY
2011-02-01
CALIFORNIA
MONTCLAIR
2011-02-01
//SYSIN DD *
DATA state;
INFILE INDD;
INPUT #1 state $20.
#2 city $20.
#3 entdate $10.
;
RUN;
PROC PRINT DATA=state;
RUN; |
_________________ Regards,
Chandra |
|
Back to top |
|
|
expat Intermediate
Joined: 01 Mar 2007 Posts: 475 Topics: 9 Location: Welsh Wales
|
Posted: Thu Jun 09, 2011 5:44 am Post subject: |
|
|
chandra, did you test that before posting ? _________________ If it's true that we are here to help others,
then what exactly are the others here for ? |
|
Back to top |
|
|
chandra Beginner
Joined: 26 Sep 2003 Posts: 130 Topics: 36
|
Posted: Thu Jun 09, 2011 7:58 am Post subject: |
|
|
Yes Expat,
I am getting following results
Code: | OBS state city entdate
1 New YORK BUFFALO 2011-01-01
2 NEW YORK ALBANY 2011-02-01
3 CALIFORNIA MONTCLAIR 2011-02-01 |
_________________ Regards,
Chandra |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Thu Jun 09, 2011 11:16 am Post subject: |
|
|
Unfortunately, those are not the requested results. . .
di |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Thu Jun 09, 2011 11:42 am Post subject: |
|
|
papadi wrote: | Unfortunately, those are not the requested results. . .
|
I agree chandra's input and output are differently formatted then OP's post. But unless we are trying to spoon feed, the required logic of row pointers is there. _________________ Regards,
Diba |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Thu Jun 09, 2011 3:28 pm Post subject: |
|
|
If something is delivered that does not match the request, mentioning that this was intentional might be helpful. . .
Something like "While the output is not exactly as requested, the posted code does show how to use pointers to get to the data you want". _________________ All the best,
di |
|
Back to top |
|
|
taltyman JCL Forum Moderator
Joined: 02 Dec 2002 Posts: 310 Topics: 8 Location: Texas
|
Posted: Thu Jun 09, 2011 4:33 pm Post subject: |
|
|
What... you guys aren't going to complain that chandra also keyed in the input wrong and did not capitalize every letter in New YORK?
The actual answer to the OP's question is
Yes
|
|
Back to top |
|
|
sub Beginner
Joined: 30 Jan 2007 Posts: 20 Topics: 12
|
Posted: Thu Jun 09, 2011 8:23 pm Post subject: |
|
|
Thanks Chandra. It works for me now. |
|
Back to top |
|
|
chandra Beginner
Joined: 26 Sep 2003 Posts: 130 Topics: 36
|
Posted: Fri Jun 10, 2011 12:37 am Post subject: |
|
|
Hi Papadi,
I assumed that the OP has mentioned State, City and date in the input data to understand the data not as a part of data.
If you look at my original post I have removed Statem City and date headings from my input data. _________________ Regards,
Chandra |
|
Back to top |
|
|
|
|