Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Finding Data Set Output from Running SAS Code

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Finding Data Set Output from Running SAS Code

Hi all,


I am a beginner at SAS. In my project, tried to run a piece of code to programmatically create a data set from an existing one with a new variable that has a value conditional on another existing variable. This is the code I ran:

 

data EMPDUP;
set EMWS1.Ids3_DATA;
MED_DUM = .;
If MEDV >= 25 THEN MED_DUM = 1;
run;

 

It runs the SAS code node fine, but I just can't seem to find where this EMPDUP dataset is. Any help would be appreciated.


Accepted Solutions
Solution
‎05-10-2016 08:58 PM
Moderator
Posts: 238

Re: Finding Data Set Output from Running SAS Code

Unless you're playing around with some advanced SAS options, when you create a table without a library reference, the default location for the newly created table is the WORK library.

 

So the following two statements are effectively identical:

 

data EMPDUP;
	set EMWS1.Ids3_DATA;
	MED_DUM = .;
	If MEDV >= 25 THEN MED_DUM = 1;
run;

data WORK.EMPDUP;
	set EMWS1.Ids3_DATA;
	MED_DUM = .;
	If MEDV >= 25 THEN MED_DUM = 1;
run;

As to where your table is PHYSICALLY located, run the following code to reveal the location of your WORK library location (Note: This location will most likely be different every time you run SAS)

 

%put %sysfunc(pathname(WORK));

View solution in original post


All Replies
Solution
‎05-10-2016 08:58 PM
Moderator
Posts: 238

Re: Finding Data Set Output from Running SAS Code

Unless you're playing around with some advanced SAS options, when you create a table without a library reference, the default location for the newly created table is the WORK library.

 

So the following two statements are effectively identical:

 

data EMPDUP;
	set EMWS1.Ids3_DATA;
	MED_DUM = .;
	If MEDV >= 25 THEN MED_DUM = 1;
run;

data WORK.EMPDUP;
	set EMWS1.Ids3_DATA;
	MED_DUM = .;
	If MEDV >= 25 THEN MED_DUM = 1;
run;

As to where your table is PHYSICALLY located, run the following code to reveal the location of your WORK library location (Note: This location will most likely be different every time you run SAS)

 

%put %sysfunc(pathname(WORK));
New Contributor
Posts: 3

Re: Finding Data Set Output from Running SAS Code

Hi Andrew,

 

This was the perfect answer. I ran the filepath code to find where the dataset was and moved it into the project. It imported as a data source perfectly.

 

Thanks again!

Super User
Posts: 17,784

Re: Finding Data Set Output from Running SAS Code

Interestingly, that was not the code you posted on SO.

 

Here, you're using a library, EMWS1, as your source data. If you use the same library for the output data, is it in your project automatically?

 

data EMWS1.EMPDUP;
set EMWS1.Ids3_DATA;
MED_DUM = .;
If MEDV >= 25 THEN MED_DUM = 1;
run;
New Contributor
Posts: 3

Re: Finding Data Set Output from Running SAS Code

Hi Reeza,

 

Haha, it's great seeing you around here too! Smiley Happy 

 

Yeah, I had a misunderstanding of how to use the DATA statement. I didn't know you had to preface it for the relevant library. The example I put on SO was with generic names to make it simpler.

 

Thanks again for all the help. Project is going smoothly! Smiley Happy

Super User
Super User
Posts: 7,400

Re: Finding Data Set Output from Running SAS Code

As you learning, I would just like provide some tips.  Look at the code people post here, particularly the formatting, indetation, casing, and not using shorthands.  Code should be readable above all else, then it should be efficient.  So for the code you posted:

data work.empdup;
  set emws1.ids3_data;
  med_dum=.;
  if medv >= 25 then med_dum=1;
run;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 344 views
  • 2 likes
  • 4 in conversation