BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bananas
Fluorite | Level 6

I have a data set with about 5000 values. I have 5 categories. Say one of the categories is weight. I need to multiply every value in the weight column by 8. How would I put in the syntax for that?

 

I tried:

data transform;
set lab.values;
weight2= weight*4;
run;

But nothing happens. can anyone help me please?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:
A DATA step program doesn't display anything but LOG messages. It looks like you successfully created WORK.TRANSFORM. If you want to look inside WORK.TRANSFORM, a handy procedure is PROC PRINT which should immediately come after the DATA step in your program. Or, you can find the data set listed in the library and open the data set or browse the data set using the table viewer. If you are using SAS Studio, you can just double click on the data set name in the library to view it. Otherwise try this:

proc print data=work.transform(obs=10);
run;

This should display the first 10 rows in WORK.TRANSFORM. If you want to see all 8327 rows, then remove the (obs=10) from the PROC PRINT statement.
I am a bit confused though. If you want to multiply the original weight by the number 8, why does your code only multiply by the number 4???
Cynthia

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

First, look for errors or warnings in the log. (See Maxim 2) What do they say?

 

What do you mean nothing happens? Please show us a portion of the output data set named TRANSFORM.

--
Paige Miller
Bananas
Fluorite | Level 6

This is what the log says. there is no output. Nothing happens.

 

NOTE: There were 8327 observations read from the data set LAB.NUTRITION.
NOTE: The data set WORK.TRANSFORM has 8327 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds

 

Cynthia_sas
Diamond | Level 26

Hi:
A DATA step program doesn't display anything but LOG messages. It looks like you successfully created WORK.TRANSFORM. If you want to look inside WORK.TRANSFORM, a handy procedure is PROC PRINT which should immediately come after the DATA step in your program. Or, you can find the data set listed in the library and open the data set or browse the data set using the table viewer. If you are using SAS Studio, you can just double click on the data set name in the library to view it. Otherwise try this:

proc print data=work.transform(obs=10);
run;

This should display the first 10 rows in WORK.TRANSFORM. If you want to see all 8327 rows, then remove the (obs=10) from the PROC PRINT statement.
I am a bit confused though. If you want to multiply the original weight by the number 8, why does your code only multiply by the number 4???
Cynthia

Bananas
Fluorite | Level 6

Hi Cynthia, 

 

the proc print worked. Thank you. It says 4 because I was trying the same step on different categories.  One of the categories, I have to multiply by 4. Thank you again for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1808 views
  • 1 like
  • 3 in conversation