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..
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.
It may also help to show the code where you intend to use the resulting variables.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.