BookmarkSubscribeRSS Feed
gsk
Obsidian | Level 7 gsk
Obsidian | Level 7

Hi, the idea is this.. I have data like this:

data have;
input col1 $ col2 $ col3 $;
datalines;
A b file1
A c file2
A b file3
B b file4
B c file5
A b file6
B b file7
C a file8
C b file9
C a file10
;

Depending on the combination of col1 and col2, I need to call in files from a directory and stack them together. 

 

file1, file3, file6 need to be "SET" together because they all have A for col1 and b for col2. 

file2 will be called in and be "SET" alone because it's the only dataset with A for col1 and c for col2. 

Likewise, file4 and file7 together. file5 alone. file8 and file10 together. file9 alone.

 

Could someone please help me start off? How do I divide col3 into file1&file3&file6, file2, file4&file7, file5, file8&file10 based on their combined values from col1 and col2? 

 

Thanks a lot in advance.. 

2 REPLIES 2
Reeza
Super User

You could pass the list to a macro using call execute. Sort your data first so that your groups are ordered the way you want, and then import the files in the grouped order. 

ballardw
Super User

It may also help to show the code where you intend to use the resulting variables.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 325 views
  • 0 likes
  • 3 in conversation