BookmarkSubscribeRSS Feed
StickyRoll
Fluorite | Level 6

Hi, I am trying to use filename _fout statement to output .sh file instead of proc export because I see that filename _fout can support permissions parameter. By Default, using proc export will not generate .sh file with executable permissions. Using filename _fout allows doing so.

 

%let default_dir=/sas/config/Lev1/AppData;
%let filename=test.sh;
%macro test();
	data a;
	attrib command length=$1000.;
		%do j=1 %to &count;
			command="cp &default_dir./&&filename&j. &sas_app_root./csv/";
			output;
			command="unzip &sas_app_root./csv/&&filename&j. -d &sas_app_root./csv/";
			output;
			command="rm -f &sas_app_root./csv/&&filename&j.";
			output;
	
	
	    %end;
		run;
%mend;
%test;


%macro output();
filename _fout "&default_dir./csv/csv_poc.sh" permission='A::u::rwx,A::g::r-x,A::o::---'; 
	data _NULL_;
/* 	set WORK.shell_command; */
      file _fout;
		%do j=1 %to &count;
			put bbb;
			
	    %end;
  	 run;
   filename _fout;
   %mend;
%output;

I couldn't find a way to let filename function to take in value from work.a;

Also, it seems like it will not output bbb in the .sh file using my script.

 

What did I do wrong?

1 REPLY 1
ballardw
Super User

Did you have working code before you attempted this macro approach? If so, show us that code.

 

You do not show where the macro variable COUNT is assigned a value. So that is one likely problem point.

 

You do not appear to actually use data set A anywhere. Then  your "Output" macro attempts to use a variable BBB that does not have a source to come from (no data set on a SET statement as shown) and your Work.A data set if created would only have one variable, Command, not BBB as attempted.

 

Any path used in a Filename statement should start at a drive (WINDOWS) or drive mount point, otherwise it is going to be treated as relative to the current operating directory and not pointing where you think it is.

What did your log look like when submitting this code.

 

 Set: OPTIONS MPRINT; then run the macro and show us the LOG of the result to see the code you are actually generating.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 196 views
  • 0 likes
  • 2 in conversation