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?
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
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.
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
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
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.