- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need help changing my year variable into a dummy variable, so i can run this macro.
The variable year variable is currently a numeric variable (2010-2017).
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Most likely, you will end up using YEAR as is. Analytical procedures will normally let you use this statement:
class year;
That will create dummy variables as needed.
If you really have to have a dummy variable, one dummy variable is not enough. You have 8 values for YEAR. You will need 7 dummy variables (rarely 8, depending on your intentions). Does that fit your plan?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If i have to create a dumme wouldn´t it be
2010=0
2011=1
........
2017= 8 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you successfully did something along these lines:
2010=0
2011=1
2012=2
...
2017=7
You would be no better off than if you had done nothing. The original variable YEAR with values 2010-2017 could have been used any place these new values could be used.
If you want advice about using a set of values within a macro, you might need to post the macro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here's one way, data step methods:
*declare an array;
array _years(2012:2017) year2012-year2017;
*set all values to 0 initially;
do i=lbound(_years) to hbound(_years);
_years(i) = 0;
end;
*assign year to 1;
_years(year) = 1;
and here's another, more automated:
PS please post your code as text not as an image. An image means if we wanted to modify or include your code we have to type it out.
@Tobiasp94 wrote:
I need help changing my year variable into a dummy variable, so i can run this macro.
The variable year variable is currently a numeric variable (2010-2017).Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But i can´t get it to work in my model.
The idea is that year will take a value of time=1 time=2 time=3 etc.
Thank you for your quick response
%let yvar=COPD;
%let xvars=Healthexpenditure Share_18_66 Share67_ Healthcosts Healthcosts_cofinancing Costelderlyadults Incomefromtaxes Costsports Socioeconomicindex Vocationaleducation Furthereducation Westerns Nonwesterns Dailysmokers Heavysmokers Physicalactivity Unhealthydiet Alcohol Familycontact;
%let wset=wnykom94;
%let datset=final;
%let region=Kkode;
%let time=year;
libname wcat '/folders/myfolders/sasuser.v94';
data set1; set work.&datset;
data sety; set set1; by year;if first.year;
yearch=put(year,4.);
proc iml;
print 'SUR model, assuming equal coefficients across time periods',,;
use set1;
yname={&yvar};
read all var yname into y;
xname={&xvars};
incxname={'Constant'}||xname;
read all var xname into x0;
use sety;
read all var {'year'} into year;
read all var {'yearch'} into yearch;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You are doing some type of modeling in IML.
Unless it is a modeling technique not available elsewhere in SAS, don't do it in IML. Save yourself a lot of trouble, use the modeling PROCs that SAS has built and debugged, most of which use the CLASS statement so you don't have to create your own dummy variables.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would like if you could give me the specific kode since im not use to work in SAS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Time = year - 2010;
Couldn't you just use Time instead of Year within IML?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What if a implemented the class year statement in my dataset before i implemente the dataset in my macro?
What would the specific code be then?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content