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
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?
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?
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
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.
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.