Hi, I need help in creating/adding a new column onto an existing data..I need to add new column and rename it as 'notes', then rename all the column values as 'Baseline' under 'notes' column
Data Have ( Table name = financial_transactions)
policy_no Amount
1 100
2 200
3 300
4 400
Data Want
policy_no Amount Notes
1 100 baseline
2 200 baseline
3 300 baseline
4 400 baseline
Like this?
data have;
input policy_no Amount;
datalines;
1 100
2 200
3 300
4 400
;
data want;
set have;
retain notes 'baseline';
run;
Like this?
data have;
input policy_no Amount;
datalines;
1 100
2 200
3 300
4 400
;
data want;
set have;
retain notes 'baseline';
run;
Absolutely perfect..its working as expected. thank you very much
Anytime
Hello,
Are you sure you need to do that ? If your dataset is big, you will use a lot of additional storage space for very few information (no observation specific information).
Maybe, you could just use a macrovariable :
%let notes=baseline;
Or, if you have different datasets with distinct notes, you can create
a dataset which associates dataset names to their corresponding notes.
data notes;
input dsname $ notes $;
cards;
have baseline
...
;
run;
What will this new column eventually be used for ?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.