BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jorquec
Quartz | Level 8
Hi, 
Could some one tell me how I could change this code on the STEP 3 to export as a SAS  table  instead of a txt file , keeping the same path to be exported I mean keeping this adress   "OUTFILE='//SASCommon/jorquec/"
 
Many thanks , 
 
 
 
 
/*-----------------MACROS DE DATA ------------------*/
 
%let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
 
data _null_;
 
date2=intnx("month",&today.,-1,'end');
call symput('ONEDT2',"1"||substr(put(date2,DDMMYYN.),7,2)||substr(put(date2,DDMMYYN.),3,2)||substr(put(date2,DDMMYYN.),1,2));
%put &ONEDT2.;
%put ONEDT2=  &ONEDT2.;
 
 
month_id = intck('month','01jan1990'd,today());
put month_id=;
call symputx('month_id',month_id);
%put month_id=&month_id;
 
run;
 
/*STEP 1 */
 
Proc SQL;
connect to teradata 
(user=&teradata_user. password=&teradata_pwd. server = 'edwprod' database = 'nuc_pl_user_view');  
Create  table JORQUEC.TESTPAYG as select * from connection to teradata(
 
 select a.ID,  a.maxmargin_dt, b.maxmodelmart_d from 
(  
  select  
1 as ID,
  max(month_end_dt) as maxmargin_dt
from nuc_pl_user_view.pg_margin_stack) as A
left join (
select  
1 as ID,
max(month_id) as maxmodelmart_d
 from  Insights_rm.Consumer_Model_Mart) as B
on a.ID = b.ID
 
 );
disconnect from teradata ;
QUIT;
 
/* STEP 2 */
 
DATA JORQUEC.TRIGGERPAYG;
SET JORQUEC.TESTPAYG;
IF  (maxmargin_dt >= (&ONEDT2.)/100) and (maxmodelmart_d = &month_id.) then export_flag='Y'; 
else export_flag='N';
 
call symputx('export_flag', export_flag);
 
run;
 
*check value of macro variable;
%PUT Export_Flag = &export_flag;
 
/* STEP 3 - PROC EXPORT -*/
 %macro test;
%if (&export_flag = 'Y') %then %do;
 
 PROC EXPORT DATA=JORQUEC.TRIGGERPAYG
 OUTFILE='//SASCommon/jorquec/TRIGGER_PAYGO.TXT'
 DBMS=dlm 
 REPLACE;
  delimiter='&';
 RUN;
 
%end;
 %mend;
 %test;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
libname export '//SASCommon/jorquec';

proc copy inlib=jorquec outlib=export memtype=data;
select triggerpayg;
run;

/* or very simple */

data export.triggerpayg;
set jorquec.triggerpayg;
run;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User
libname export '//SASCommon/jorquec';

proc copy inlib=jorquec outlib=export memtype=data;
select triggerpayg;
run;

/* or very simple */

data export.triggerpayg;
set jorquec.triggerpayg;
run;
jorquec
Quartz | Level 8
Many thanks, sorry for my basic question I am still learning. You are very kind.
Kurt_Bremser
Super User

No problem. See it as "my job" here 😉

There are, as always with SAS, many more ways to create SAS tables in a given location. Proc sql, ODS output, to name just two.

For a single table, the data step is probably best (because of being simple), for a "bulk" operation proc copy is the tool of choice. 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 558 views
  • 0 likes
  • 2 in conversation