BookmarkSubscribeRSS Feed
patrick85
Fluorite | Level 6

Hello,

 

Please, can someone assist me with this question. I want to add another column to my data set in sas studio which has 138435 observations and 22 variables. I would like the new column to be the 23 variable.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

If you want code, here is an example:

 

data want;
     set have;
     twenty_third_variable=temperature_celsius*9/5 + 32; /* or any other value you want */
run;

If you want to do this via menus only, then I defer to others.

--
Paige Miller
jimbarbour
Meteorite | Level 14

Can you tell us the source of the column?  Will it be from another SAS dataset?  Is it based on a calculation (as in @PaigeMiller's response)?  Is it from a file?  A database?  How will you obtain this value? 

 

Adding a new column to a SAS dataset is pretty easy.  Say you have an existing data set, let's call it "Have."  If you want to add a column to the data, one way is a Data step, for example, the below.  In my existing data, if I have a column named "Centimeters" but I want a new column called "Inches," I can create a new column by using the standard conversion formula as shown.

Data Want;
    Set Have;
    Inches = Centimeters / 2.54;
Run;

The output of the above Data set will be a new dataset named "Want".  The new data set will be a copy of Have but will have a new column added to, a column named "Inches."

 

Jim

 

PaigeMiller
Diamond | Level 26

To re-phrase @jimbarbour comments into Paige-speak:

 

Be specific. By providing more information and specific information, you will get faster and better answers.


General and vague questions get general and vague answers. Specific questions get specific answers.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 3091 views
  • 4 likes
  • 4 in conversation