BookmarkSubscribeRSS Feed
VMn
Calcite | Level 5 VMn
Calcite | Level 5

Hi,
I'm very new to SAS and have been struggling to accomplish this seemingly simple task. For starters, perhaps it's best I describe what I'm trying to achieve.

Our organization has a customer who wishes to streamline their process by running a program that downloads a specific file into their SAS environment. We both have SAS environments although I'm using SAS Studio Viya LTS and they're using "SAS desktop" (i'm honestly not sure what they're meaning though with that term).

What i've gathered so far, is that before they can download anything, we need to produce a physical file. i've done that by running

proc casutil;
    save casdata="filename" incaslib="src" outcaslib="public" casout="filename.csv" replace;
run;

If I navigate to the Public folder within Manage Data I can see the file there. Additionally, if I also run:

proc cas;
    table.fileinfo / caslib="Public";
quit;

proc cas;
    session mySession;
    caslibinfo /;
quit;

I can also see it.

It's at this point that I'm stuck. I've tried using the following:

%macro get_csv;
    ods _all_ close;

    filename jobout filesrvc folderpath='/Public/' filename="filename.csv";

    %let file_exists = %sysfunc(fexist(jobout));

    %put File exists: &file_exists;
%mend;
%put %get_csv;

The output of that though is 0 which I don't understand since I can visually see that it's indeed in the Public folder. 

What am I missing and what can I add to this to solve the problem?

3 REPLIES 3
Patrick
Opal | Level 21

We both have SAS environments although I'm using SAS Studio Viya LTS and they're using "SAS desktop" (i'm honestly not sure what they're meaning though with that term).

SAS Studio is a client with which you can access a SAS Server environment. SAS desktop could mean that they are running a locally installed SAS (="server" on a PC) which would be a totally different environment than what you've got. The first thing you need to figure out is a location (path) that's accessible both to you (your SAS server) and your customer.

 

From what you describe you're creating the file successfully under /public/ which appears to be the physical leg of your caslib public.

 

/public/ is not the actual physical path which is why you need to access the file via the filesrvc filename engine. 

Again based on your description the actual filename works and the only thing that's surprising is that %sysfunc(fexist(jobout)) returns 0 and not 1. 

 

If all of the above is true then it's possible that fexist() isn't working as expected with filesrvc filename engine. 

 

If no one else comes up with a better explanation then I'd contact SAS Tech Support. 

 

...but of course to solve your actual problem you need to figure out where to deliver the data to so it's accessible to your customer.

And given that you are very new to SAS: Is your source data actually loaded into CAS (memory) or is that just something you're doing for creating the .csv the way you know how to do? 

 

VMn
Calcite | Level 5 VMn
Calcite | Level 5
Is your source data actually loaded into CAS (memory) or is that just something you're doing for creating the .csv the way you know how to do? 

Thanks for your response!

It's both in memory and physical.
I omitted showing this step in the job flow:

proc casutil;
    promote casdata="FILENAME"	
    incaslib="OUR_LIB"          
    casout="FILENAME"   			
    outcaslib="Public";        
run;

Is there a way of loading the data from caslib, compiling it to a csv and sending it that way? I remember seeing a macro for streaming a .csv but I can't figure out what i did with the link. I do remember it was via githubuser and some sasmaster path or something though.

Patrick
Opal | Level 21

Data in CAS won't be a csv. The csv can be the physical leg of the in-memory CAS table.

 

Where I was going to was more: In Viya there is SAS Compute and CAS. SAS Compute is "traditional SAS". CAS is in-memory SAS with a physical source defined to save data (so it can for example get reloaded when the CAS server needs a restart that wipes out memory). 

 

You don't need to load data into CAS for writing it out as a csv file. If the data is not anyway in CAS then I'd be using SAS Compute.

 

SAS Studio is a client that connect to a SAS Server. Your SAS Viya server (that's where things actually happen) is likely a cloud based environment. "SAS Desktop " likely refers to a SAS9.4 version that's locally installed on the users PC's.

 

For you the first bit to solve before any coding is how you can deliver a csv file (or any file) from your environment to a location your customer can read from. Is there any location your SAS environment (server side where SAS executes) can access that's also accessible by your customer (and if it's a locally installed SAS then a path directly accessible from their PC).

 

If there isn't such a share location then you will need to look into another delivery mechanism like writing to share point, sending and email with attachment, ...or whatever else works, is technically available and meets the requirements. 

 

Once you know how/where to deliver the csv/the data exchange mechanism then the rest is very solvable.

 

Btw: If this is a one-off then you can just download the .csv to your local environment via SAS Studio.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 711 views
  • 1 like
  • 2 in conversation