BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User

@Decay2020 wrote:

Yes, you are partially right. As I tried to give a simple example to get an idea about the solution, but the reality is completely different. Just imagine there are hundreds of columns instead of just 3 (namely A, B , C)  in table 'Have' and we don't know if we have all the combination of those in var1 and var2 in the table 'want'. Now we are interested in getting only the values with respect to those combinations that are present in Table 'want'. Let me know if I was able to explain the things further. 

 


Doesn't matter, it doesn't change my solution.

The number of rows are irrelevant and the number of columns can be easily referenced using shortcut lists.

 

Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html

 


@Decay2020 wrote:

 Now we are interested in getting only the values with respect to those combinations that are present in Table 'want'. Let me know if I was able to explain the things further. 

 



Then why work with the whole data set at all? Generate your list from your WANT data set and merge it in. Unless there's something else you're not explaining this looks like a standard look up problem. Another approach that make more sense to the way you seem to be thinking is to load it into a two dimensional temporary array. If you provide a full example of input and expected output I'll take a stab at coding that. Please post your data as a data step following the instructions below. 

 

Make sure to include both your exact input and the matching expected output. If you cannot provide real data, make fake data that's representative of your problem. 

 

Instructions on how to provide sample data is here:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

 

 

 

 

Reeza
Super User
FYI more common terms for this task are transpose or pivot. If you search with those terms in any language you'll find an answer.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 16 replies
  • 4312 views
  • 4 likes
  • 3 in conversation