Hi Everyone,
I am new to SAS, and am not a coder by trade but can get by with small things. My platform is the Mainframe.
My situation is I have 4 datasets, each of these datasets collect the same 2 variable but each dataset variable has a slightly name different.
Variable 1: These are the 4 variable names that contain a 4 character BUCS code. In each dataset, the BUCS code will have multiple instances so I have to summarize into 1 and add the total seconds with associated variable to, CPU time.
CICACT2 / IMSACT2 / DB2IACT3 / ACCTNO2 = BUCS $char4
Variable 2: These are the 4 variable names that contain the CPU TIME in seconds. The
CSUCPUTM / ISUCPUTM / DSUCPUTM / PGMCPUTM = CPU time (seconds)
Seems like a fairly easy task for a seasoned programmer.
I was looking at MEAN/SUMMARY , TYPE, and the CONCATENATION part of the DOCS but didnt find what I want.
Thanks,
You can combine data sets and rename them all to the same name in a data step.
Suppose I have some data sets with the same "variable" but slightly different name in several sets, such as ABC1 ABC2 and ABC3 (actual names aren't important but just to tell them apart) and that I would like to just have the name ABC for consistency:
data want; set have1 (rename=(ABC1 = ABC)) have2 (rename=(ABC2 = ABC)) have3 (rename=(ABC3 = ABC)) ; run;
So each record in the result would have values for ABC from the sets.
Note the RENAME done this way is done in pairs of Oldname=newname. You could rename multiple variables such as
have1 (rename=(ABC1 = ABC thisname=thatname rate=newrate))
or what have you.
@sasfreaky
It's not clear to me what you want to achieve, a simple example would be helpful.
Having said that here's an example that might be similar to what you are trying to achieve
data table_1 ;
input
cicact2 $
csucputm ;
cards ;
AAAA 5
BBBB 6
CCCC 3
DDDD 4
;
data table_2;
input
imsact2 $
isucputm ;
cards ;
AAAA 5
BBBB 6
CCCC 3
DDDD 4
;
/* Combine the tables */
data both ;
set table_1 table_2 (rename=(imsact2=cicact2 isucputm=csucputm)) ;
run ;
/* Create summary output */
/* https://go.documentation.sas.com/?docsetId=proc&docsetTarget=p0aq3hsvflztfzn1xa2wt6s35oy6.htm&docsetVersion=9.4&locale=en */
proc summary data=both ;
output out=summary sum=sumvar ;
class cicact2 ;
var csucputm ;
run ;
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.