data one;
set project1;
consg = (consumption*42)/Population;
pce0 = PCE/78.23517;
rpgas = Price/pce0;
logrpgas = log(rpgas);
logconsg = log(consg);
logincome = log(income);
logPCE_lag = log(PCE_lag);
logUnemployment = log(Unemployment);
logOneyear = log(Oneyear);
num_mon= month (observation_date);
If num_mon=1 then dumjan=1; else dumjan=0;
If num_mon=2 then dumfeb=1;else dumfeb=0;
If num_mon=3 then dummar=1;else dummar=0;
If num_mon=4 then dumapr=1;else dumapr=0;
If num_mon=5 then dummay=1;else dummay=0;
If num_mon=6 then dumjun=1;else dumjun=0;
If num_mon=7 then dumjul=1;else dumjul=0;
If num_mon=8 then dumaug=1;else dumaug=0;
If num_mon=9 then dumsep=1; else dumsep=0;
If num_mon=10 then dumoct=1; else dumoct=0;
If num_mon=11 then dumnov=1; else dumnov=0;
If num_mon=12 then dumdec=1; else dumdec=0;
is this how you take logs of variables and set dummy variables? The reason I ask is because this is the format in sas studios but SAS 9.4 might be different.
I can't see anything immediatly wrong with it.
I assume you also have a run; statement at the end of the code .
Are you getting any errors in your logs?
Is the output as you expect ?
do you know what the LOG function does?
No it doesn't . I suggest you check out google.
Some clarifications for you, SAS UE is running SAS 9.4 TS1M6 at the moment. This is the same as SAS 9.4. There are some differences between using SAS UE and one on your desktop but it's more related to file paths than any type of functionality about your actual code.
Regarding LOG:
Yeah it turns my values into percent form.
The log function most definitely does not convert a number to a percent, it takes the natural log of a number. Most likely you're getting errors because you can't take the log of a negative, zero or missing value.
Returns the natural (base e) logarithm.
Regarding creating the dummy variables, you could simplify that by using an array, see the examples here, specifically see the example titled "Computing New Variables"
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
When you're having issues with your code, it's helpful if you include the log that shows what errors you're encountering.
data one;
set project1;
consg = (consumption*42)/Population;
pce0 = PCE/78.23517;
rpgas = Price/pce0;
logrpgas = log(rpgas);
logconsg = log(consg);
logincome = log(income);
logPCE_lag = log(PCE_lag);
logUnemployment = log(Unemployment);
logOneyear = log(Oneyear);
num_mon= month (observation_date);
If num_mon=1 then dumjan=1; else dumjan=0;
If num_mon=2 then dumfeb=1;else dumfeb=0;
If num_mon=3 then dummar=1;else dummar=0;
If num_mon=4 then dumapr=1;else dumapr=0;
If num_mon=5 then dummay=1;else dummay=0;
If num_mon=6 then dumjun=1;else dumjun=0;
If num_mon=7 then dumjul=1;else dumjul=0;
If num_mon=8 then dumaug=1;else dumaug=0;
If num_mon=9 then dumsep=1; else dumsep=0;
If num_mon=10 then dumoct=1; else dumoct=0;
If num_mon=11 then dumnov=1; else dumnov=0;
If num_mon=12 then dumdec=1; else dumdec=0;
is this how you take logs of variables and set dummy variables? The reason I ask is because this is the format in sas studios but SAS 9.4 might be different.
If num_mon=1 then dumjan=1; else dumjan=0;
If num_mon=2 then dumfeb=1;else dumfeb=0;
If num_mon=3 then dummar=1;else dummar=0;
If num_mon=4 then dumapr=1;else dumapr=0;
If num_mon=5 then dummay=1;else dummay=0;
If num_mon=6 then dumjun=1;else dumjun=0;
If num_mon=7 then dumjul=1;else dumjul=0;
If num_mon=8 then dumaug=1;else dumaug=0;
If num_mon=9 then dumsep=1; else dumsep=0;
If num_mon=10 then dumoct=1; else dumoct=0;
If num_mon=11 then dumnov=1; else dumnov=0;
If num_mon=12 then dumdec=1; else dumdec=0;
A comparison operator returns a boolean result, i.e. false=0, true=1.
So the above can be shortened to:
dumjan = (num_mon=1);
dumfeb = (num_mon=2);
dummar = (num_mon=3);
dumapr = (num_mon=4);
dummay = (num_mon=5);
dumjun = (num_mon=6);
dumjul = (num_mon=7);
dumaug = (num_mon=8);
dumsep = (num_mon=9);
dumoct = (num_mon=10);
dumnov = (num_mon=11);
dumdec = (num_mon=12);
Which can be further shortened to:
array months {12} dumjan dumfeb dummar dumapr dummay dumjun dumjul dumaug dumsep dumoct dumnov dumdec;
do i=1 to 12; (or do i=1 to dim(months))
months{i}=(num_mon=i);
end;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.