BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
radha009
Quartz | Level 8

i have 4 datasets  jan_Data,feb_data,march_data,April data

 

All tables variable names are same ( ID,name,owner,val_requred (yes/No)

 

jan_data - dataset:

 

A451  oranges peter yes

B345   Apples  sam   No

B123    berry    john   yes

 

Feb_data - dataset:

 

A451  oranges peter  No

B123    berry    john   yes

C125    grape   rob   yes

Expected result:

ID         name    owner    val_req_jan      val_req_feb         val_req_mar

A451  oranges   peter        yes                      No

B123    berry    john            yes                      yes

B345   Apples   sam          No

C125    grape   rob                                        yes

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

One way IF all the data sets are sorted by id name and owner

data want;
   merge jan_data    (rename=(val_required = val_req_jan))
         feb_data    (rename=(val_required = val_req_feb))
         march_data  (rename=(val_required = val_req_mar))
         april_data  (rename=(val_required = val_req_apr))
   ;
   by id name owner;
run;

For a large number of analysis you might be better off by setting the sets and adding a variable that holds the month and likely as an actual date. Things would sort as needed using a date and any analysis /reporting would not require having to add a variable name when the May, June, July etc data is available. Not to mention ease of ordering things if you cross a calendar year border...

 

 

You also may find it helpful to change Yes/No coding with character values to numeric 1/0. Then a sum of the values would be the count yes, the mean a percentage.

How will the resulting set be used?

View solution in original post

3 REPLIES 3
ballardw
Super User

One way IF all the data sets are sorted by id name and owner

data want;
   merge jan_data    (rename=(val_required = val_req_jan))
         feb_data    (rename=(val_required = val_req_feb))
         march_data  (rename=(val_required = val_req_mar))
         april_data  (rename=(val_required = val_req_apr))
   ;
   by id name owner;
run;

For a large number of analysis you might be better off by setting the sets and adding a variable that holds the month and likely as an actual date. Things would sort as needed using a date and any analysis /reporting would not require having to add a variable name when the May, June, July etc data is available. Not to mention ease of ordering things if you cross a calendar year border...

 

 

You also may find it helpful to change Yes/No coding with character values to numeric 1/0. Then a sum of the values would be the count yes, the mean a percentage.

How will the resulting set be used?

radha009
Quartz | Level 8
Awesome. Thanks a lot.
Reeza
Super User

I'd probably APPEND the data and then use a TRANSPOSE to transform the months into a wide format. 

 


@radha009 wrote:

i have 4 datasets  jan_Data,feb_data,march_data,April data

 

All tables variable names are same ( ID,name,owner,val_requred (yes/No)

 

jan_data - dataset:

 

A451  oranges peter yes

B345   Apples  sam   No

B123    berry    john   yes

 

Feb_data - dataset:

 

A451  oranges peter  No

B123    berry    john   yes

C125    grape   rob   yes

Expected result:

ID         name    owner    val_req_jan      val_req_feb         val_req_mar

A451  oranges   peter        yes                      No

B123    berry    john            yes                      yes

B345   Apples   sam          No

C125    grape   rob                                        yes

 

Thank you


 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 701 views
  • 0 likes
  • 3 in conversation