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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.