BookmarkSubscribeRSS Feed
James_Yu
Obsidian | Level 7

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 

4 REPLIES 4
Tom
Super User Tom
Super User

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?

James_Yu
Obsidian | Level 7

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

ChrisNZ
Tourmaline | Level 20

You need to be more specific in your explanations.

Astounding
PROC Star
In general, this sounds like a need for one DATA step with several two dimensional arrays. If you want more specific help you will need to provide complete coding for one set of variables.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1149 views
  • 0 likes
  • 4 in conversation