MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to concatenate two input files in SAS

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
js01
Beginner


Joined: 13 Oct 2005
Posts: 84
Topics: 32
Location: INDIA

PostPosted: Mon Mar 15, 2010 1:15 pm    Post subject: How to concatenate two input files in SAS Reply with quote

Hi friends,

I am trying to create a SAS dataset using two input files , below are the input files

RECF=VB
LRECL=250

infile1:
Code:

filed1(7)filed2(2) filed3(5) filed4(15) filed5(7)
AAAA  BBCCCCCKKKKKKKKKKKKKKKYYYYYYY
A1BA11  012345UUUUUUUUUUUUUUUZZZZZZZ
2122   37777 TTTTTTTTTTTTTTTIIIIII

infile2
Code:

filed1(7)filed2(2) filed3(5) filed4(15) filed5(7)filed6(x) filed7(y)......
AAAA  BCCCCCKKKKKKKKKKKKKKK123455qqqqqqqquuququququququuq
2122   37777 TTTTTTTTTTTTTTTLLLLLLFFFFFFFFFFFFFDDDDDEEEEE

output should be
Code:

AAAA  BBCCCCCKKKKKKKKKKKKKKK123455YYYYYYYqqqqqqqquuq.
2122   37777 TTTTTTTTTTTTTTTLLLLLLIIIIIIFFFFFFFFFFFFFDDDDDEEEEE


infile1 and infile2 has same key ,
first file2 reads and do format (some business logic) and then the next field should be populated from infile1 where infile1key = infile2key

Please help me
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Mar 15, 2010 3:01 pm    Post subject: Reply with quote

js01,

There are tons of examples mentioned here

SAS Learning Module Match merging data files using proc sql

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
js01
Beginner


Joined: 13 Oct 2005
Posts: 84
Topics: 32
Location: INDIA

PostPosted: Mon Mar 15, 2010 4:17 pm    Post subject: Reply with quote

Thank you very much Kolusu

I am new to the SAS ,could you please is there any user defind function in SAS ,

actually i want assign a value that retuirns from function.

Regards
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Mar 15, 2010 5:10 pm    Post subject: Reply with quote

js01 wrote:
Thank you very much Kolusu

I am new to the SAS ,could you please is there any user defind function in SAS , actually i want assign a value that retuirns from function.

Regards


Js01,

What do you think the above examples show? If you want a new function " match_any_file_I_can_think_of" then may be you need to start writing one.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
js01
Beginner


Joined: 13 Oct 2005
Posts: 84
Topics: 32
Location: INDIA

PostPosted: Tue Mar 16, 2010 11:27 am    Post subject: Reply with quote

Hi Kolusu,

actually i got a requirement to add a new field to existing SAS dataset , this SAS dataset is loaded with inpufile (VB , 250 length) with business logic. input file has the packed decimal values along with chars and numbers,
i have added new field to inputfile after 250 (which will pass from previous step)


like below

DATA SAS1
INFILE infile1
INPUT @0001 key 16
@120 var2 PD
@ .......
@251 newfield $10

some busines logic
-----

the newfiled is getting populated with zigzag data , when i used fixed block file then it was having correct value (this tested with business logic)


so i am thinking to pass new value with different file ( new) to SAS,hence want to use a function which will retrun a value

like below

DATA SAS1
INFILE infile1
INPUT @0001 key 16
@120 var2 PD
@ .......
@251 newfield $10

some busines logic
-----
newfield = getvalue(key)

---------
end

function getvalue (key)
proc sort data=sas2 output=sas3
infile inputfile2
input @001 Key 16
@015 var5 $10
return var5
end

is this possible in sas, please help me
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group