DATA Step, Macro, Functions and more

How do I match the field from one dataset to another dataset name?

Reply
Occasional Contributor
Posts: 8

How do I match the field from one dataset to another dataset name?

There are 45 companies and several employee works in each company.
Each company has its unique code
EX: AA11, AA12..so on
Each emp has a unique id in 16 digit numeric format
In my SAS library I have, 90 datasets (name ends with unique code) 2 dataset for each company containing department and hiring information.
names of the text files are in following format:
Dep_code and Hinfo_code
ex Dept_AA11, Hinfo_AA11 (datasets containing Department and hiring information for each Employee id)

I have third dataset in SAS named Test which contains Employee id and company code.
Now In this dataset, I have to look company code for each Employee id and company code, then need to select the 2 datasets containing Dept and Hiring info from the library ending with the matching code and then create a report containing both the Department and Hiring info.
i.e. from the dataset, check the company code for each employee id , and then select 2 department and hiring datasets for the matching company code and match the employee id, get the Department and hiring info and create the report.

I am new to sas..How should I start.
Any suggesstion is appreciated.

Thanks,
sasuser
Respected Advisor
Posts: 4,173

Re: How do I match the field from one dataset to another dataset name?

Is this real life or study excercise?
Super Contributor
Super Contributor
Posts: 3,174

Re: How do I match the field from one dataset to another dataset name?

It's likely that the SAS DATA step process can be used to SET on all company/hiring files if using SAS 9.2, where you can use SET DEPT: (that's a colon character), and also you didn't mention if a SAS variable department (dep_code) is in the DEPT_: / HINFO_: files. If not, you can interrogate the input file using the SET statement parameter INDSNAME= to interrogate what SAS file is inputting the current observation and capture the file-name suffix to assign dep_code.

Either a PROC FORMAT for VALUE look-up or a SAS DATA step MERGE process (with a BY statement and your match-variable list), will work with your SAS programming task to combine the different, but related input files.

And, PROC PRINT or PROC REPORT can be used to generate a suitable report.

You may also find that some tasks can be performed by PROC SQL, if you prefer that language technique.

Suggest you make use of the SAS discussion forum archives and the SAS support http://support.sas.com/ website for SAS-hosted documentation and supplemental technical / conference reference materials.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

data step programming intro site:sas.com

data step merge by processing site:sas.com

set statement indsname site:sas.com

proc format table lookup site:sas.com

elearn site:sas.com
Ask a Question
Discussion stats
  • 2 replies
  • 125 views
  • 0 likes
  • 3 in conversation