BookmarkSubscribeRSS Feed
sasismylife
Fluorite | Level 6

Hi All,

 

I would like to create the .sas file from sas code. Could you please help me how to create the .sas files.

Am using sas 9.4 version.

 

Any help would be greatly appreciated.

 

Thanks in advance.

 

 

3 REPLIES 3
gamotte
Rhodochrosite | Level 12
File -> Save as... ?

Please be more specific : what file do you want to create from which code ?
sasismylife
Fluorite | Level 6

hi gamotte,

Thanks for your reply. am creating the sas package for the sas di jobs by using the attached code like the same way i want to create the .sas files (dot sas files).

 

for this am passing the sas di job names as the input 

Filename LFYXIN01 "&FILENAME";

PROC IMPORT OUT= WORK.JOBS 
            DATAFILE= LFYXIN01 
            DBMS=TAB REPLACE;
     GETNAMES=NO;
     DATAROW=1; 
RUN;

	data test (drop=cmd);
	set JOBS;
	LNOMJOB=compress('"'!!"\\jafile01\sdtmaps\" !!substr(Var1,3,2)!!"\"!!var1!!".spk"!!'"') ;
	LNOMLOG=compress('"'!!"\\jafile01\sdtmaps\Export_Logs\"!!var1!!".LOG"!!'"') ;
*Put LNOMJOB;
cmd ='J:\SASHome\SASPlatformObjectFramework\9.4\EXPORTPackage -host SDSASA01 -port 8561 -user ' !! "&userID" !! ' -password ' !! "&user_password" !! ' -package ' !! LNOMJOB !! 
' -objects "/" -name ' !! var1 !!' -nameMatchType EQUALS -includeDesc -types "Job,ExternalFile" -excludeSubTypes -log ' !!LNOMLOG ;

	call system(cmd);
	run;

 

input 

JSYM8ABCTABLECOP

JSYM8ABCTABLEAUDBEG

JSYM8ABCTABLEAUDFIN

JSYM8ABCTABLE

for the 4 job names am creating the 4 pacakges like the same i want to create the .sas files (dot sas files).

Tom
Super User Tom
Super User

It is not at all clear what your question is.

So for each of those names you want to create a SAS program file?  What SAS code are you going to put into the file(s)? How is it going to be different for each of the values from your input file?

How is this related to SAS/DI?

 

But we can provide some feedback on the code you posted.

Why are you using PROC IMPORT to read a text file? Especially one that only has one variable? Just read the file.

You could read the full line into your character variable.

data WORK.JOBS  ;
  infile LFYXIN01 truncover ;
  input var1 $100. ;
run;

Or if it actually has tabs you can read the first column.

data WORK.JOBS  ;
  infile LFYXIN01 dsd dlm='09'x truncover ;
  input var1 :$100. ;
run;

 

To simplify your command generation. You can use the new CAT...() series of functions instead of just use in the || operator.

Also why are you using the COMPRESS() function?  Is it just to remove the trailing spaces from the variable values?  If so then use the CATS() or CATX() function which will automatically strip the leading/trailing spaces.

 

data test;
  set JOBS;
  length LNOMJOB LNOMLOG $200 CMD $1000 ;
  LNOMJOB=quote(cats('\\jafile01\sdtmaps\',substr(Var1,3,2),'\',var1,'.spk'));
  LNOMLOG=quote(cats('\\jafile01\sdtmaps\Export_Logs\',var1,'.LOG')) ;
  cmd = catx(' '
      ,'J:\SASHome\SASPlatformObjectFramework\9.4\EXPORTPackage'
      ,'-host SDSASA01'
      ,'-port 8561'
      ,'-user',"&userID"
      ,'-password',"&user_password"
      ,'-package',LNOMJOB
      ,'-objects "/"'
      ,'-name',var1
      ,'-nameMatchType EQUALS'
      ,'-includeDesc'
      ,'-types "Job,ExternalFile"'
      ,'-excludeSubTypes'
      ,'-log',LNOMLOG 
  );
  call system(cmd);
run;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 1157 views
  • 0 likes
  • 3 in conversation