Write and run SAS programs in your web browser

same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that code

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that code

Greetings to the SAS Studio saviours out there! Hope someone can help out.

 

I thought I was just starting to get the hang of SAS Studio but got stumped by something probably trivial but that I can't figure out!!

 

I have used the following proc import code to import a dataset:

 

proc import datafile="/folders/myfolders/myfile.CSV"

OUT=myworkfile

DBMS=CSV

REPLACE;

RUN;

 

this code was in a program file containing other code but I only highlighted the code above and hit the run button, e.g. without running anything else.

 

I had previously used the libname statement in that program file to create the library STUDYFILES.

 

Trying to tidy things up, I created a separate program file to copy and paste the successful code into, but re-running the exact same code from the new program file, I don't get the output data tab and I discovered the file output to WEBWORK.

 

the code I get when I get the output data is logged as follows:

NOTE: WORK.myworkfile data set was successfully created.
NOTE: The data set WORK.STUDYFILES has 879 observations and 12 variables.
 
when I run the same code from the new program file I get the following log:
USER.STUDYFILES data set was successfully created.
NOTE: The data set USER.STUDYFILES has 879 observations and 12 variables.

 

Can anyone explain what is happening? Is it to do with the fact that if there are two programs I am trying to use then they can't both output to work if the code is the same?

 

Thanks in advance guys.

 


Accepted Solutions
Solution
‎04-08-2017 12:37 AM
Super User
Super User
Posts: 6,842

Re: same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that cod

Normally when you use a one level name SAS will take it to mean a dataset in the WORK libref.

But if you have defined a USER libref then SAS will treat that one level name as being in the USER libref.

 

So whatever you did to change your sessions settings has made SAS think that you want to use USER instead of WORK for one level names.  

 

If you want to force it to always write to the WORK libref then use a two level name.

 

proc import datafile="/folders/myfolders/myfile.CSV"
  OUT=WORK.myworkfile replace
  DBMS=CSV
;
RUN;
 

View solution in original post


All Replies
Occasional Contributor
Posts: 12

Re: same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that cod

I may have made progress on this - I found the SAS Studio User Guide (version 4.2) and found out that if I swich the interactive mode OFF (I forgot I had it on to avoid overwriting log), then the results are stored in WORK and not WEBWORK.

 

However, also the original program file that stored data into WORK is set to be in interactive mode.

 

I wonder if using interactive mode is good for a beginner after all - I was reading that it keeps the code in memory until a new PROC or a data step are used . That might explain why I thought SAS Studio was having me on - perhaps best to switch if off until I am in the learning phase?

 

Suggestions/ comment from experienced folks would be great!

Super User
Posts: 19,063

Re: same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that cod

I find interactive mode easier to work with but there are some best practices to help make this better. It's good that you found the error, and working in multiple modes may be a bit confusing but knowing the difference is also a good idea. In the long run you'll be a better programmer. That being said, use the method that will be used most frequently when you're 'fully trained'. If that's batch processing then go with that. 

 

 

Occasional Contributor
Posts: 12

Re: same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that cod

Hi Reeza

thanks for your reply. Basically using interactive mode is best when you are more experinced as you may not reaize how many actions you set in motion whilst you are busy trying to figure things out?

Would you then recommend beginners not use the interactive mode until they are confident of having mastered all the basic skills?

I will look up batch processing :-)

Thanks again

Solution
‎04-08-2017 12:37 AM
Super User
Super User
Posts: 6,842

Re: same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that cod

Normally when you use a one level name SAS will take it to mean a dataset in the WORK libref.

But if you have defined a USER libref then SAS will treat that one level name as being in the USER libref.

 

So whatever you did to change your sessions settings has made SAS think that you want to use USER instead of WORK for one level names.  

 

If you want to force it to always write to the WORK libref then use a two level name.

 

proc import datafile="/folders/myfolders/myfile.CSV"
  OUT=WORK.myworkfile replace
  DBMS=CSV
;
RUN;
 
Occasional Contributor
Posts: 12

Re: same proc import code outputs to WORK from a program file but in WEBWORK with a copy of that cod

Thank you - that makes completely sense!

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 143 views
  • 1 like
  • 3 in conversation