Hi,
I have one dataset as below
Account_id Account_name Credit_balance Debit_Balance
1 Ajay 100 200
2 Vijay 300 400
Now I need something like this in the same datastep
Data changed;
Set Input;
Credit_balance_changed= ranuni("uniform") *credit_balance;
* Here this value of Credit_balance and its randomly generated
variable I need in the same datastep*
Something like below
Call execute (' proc sql; insert into new_table (select Credit_balance,
Credit_balance_changed)
But somehow I am not able to get the correct results.
Any help is really appreciated
Is the value from the other data set supposed to brought into data set Changed?
Is there some rule for which value gets brought in? Such as matching on the Account_id or Account_name?
Call execute stacks code that executes after the data step that uses it. So there isn't any way you are going to get results into the data step creating changed.
It probably would be a good idea to actually show what that "other table" that you haven't even bothered to name contains.
So you want to create a random number. Do you have any rules for how to make such?
SAS has several functions that create random numbers and one, RAND that will create random numbers from many different distributions.
Example of just a few:
data example; do i=1 to 10; rn = rand('normal',0,1); rb = rand('binomial', .5,10); rbeta = rand('beta',4,12); rchi = rand('chisquare',17); output; end; run;
You would call one of these, or other functions, to create your random number in a data step.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.