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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 1960 views
  • 4 likes
  • 4 in conversation