Hello,
Now I'm handling a dataset with nearly 100 variables (already name var1 to varxx). The situation is that these variables could be divided in to blocks (4 to 5 variables within each block) and I want to create 2 more variables from each block. The logic to create new variables is the same with all blocks.
My way of thinking is to split the original dataset to sub-datasets, each sub-dataset has one block of variables, create and split new variables, then join new variables together. My problem now is to create a loop to handle those datasets (bcs the logic to handle is the same) but the names of variables are different among datasets.
How could I deal with this situation ? Or is there any better way to deal with it in the first place
Thanks in advance
I don't see how breaking the dataset up is going to make calculating new variables any easier.
Whether there is any way to simplify the coding depends a lot on how complex the calculation is. And how consistent the grouping of the variables is. Are the there 25 groups of 4 variables? Or 20 groups of 5 variables? Or between 20 and 25 groups of between 4 and 5 variables?
In my case, there are 14 groups of 5 and 6 groups of 4. All 6 groups of 4 will be proceeded in the same way. In 14 groups of 5, 10 groups will be in one part and the remaining will be in the other part. There will be 3 ways to proceed the data to achieve 2 new variables with each group
You need to be more specific in your explanations.
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.