Help using Base SAS procedures

PROC APPEND ??

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

PROC APPEND ??

HI there,

     First of all, thanks for reading this discussion.

     i have a some code written that i want to append data that extracted from a series of csv file into one dataset.

     what i have done is i "indirectly" append by temporaly store into a temp sas table then call proc append append into a detail table.

     my code written like this:

Data etllib.TEMPSDelivered_NonDeliveredFact;

      infile indir(&fname) truncover delimiter=',' FIRSTOBS=2;

      input CardCode:$15. CardName:$100. Block:$100. StreetNo:$100. Address:$100. ZipCode:$20. State:$100. Country:$100. fatherCard:$15. CardReceipt:$100. CardReceiptID:$15. Active:$1. Region:$200. Route_Code:$8.

               Branch_Code:$8. Route_Day:$8. Delivery_Date:yymmdd10. ItemCode:$20. ItemName:$100. Quantity UOM:$20. RouteFreq:$100. Route_Sequence Route_Truck:$100. DeliveredStatus:$1. Reason:$100. LogTime:time. LogDate:yymmdd10.;

      file outdir(&Read&fname);

      put _INFILE_;

run;

proc append base=etllib.Delivered_NonDeliv data=etllib.TEMPSDelivered_NonDeliveredFact;

run;

Note:- "indir(&fname)" is a file path name that refer to a csv file.

     - TEMPSDelivered_NonDeliveredFact is a temporaly table.

     - Delivered_NonDeliv is a detail table.

PS: this process is in a nested loop.

Problem: am i just can direct append on the infile statment there instead of insert into  TEMPSDelivered_NonDeliveredFact and call

                proc append to done this job?

     Please, help me..thank you everyone...

     Thank you.

Best Regards

LiangCk


Accepted Solutions
Solution
‎10-06-2011 03:36 AM
SAS Super FREQ
Posts: 708

PROC APPEND ??

LiangCk
You can make use of DATA Step views, in this way there is no SAS Data set created by the DATA Step but a view.
The code for the view is executed when you access the view for instance when using Proc APPEND, see code below for a sample.
A question on the code sample you provided: is there a reason that you use infile/input as well as file/put, just curious.
Bruno
*
* create a DATA Step view
*;

data work.mycsv_Temp / VIEW=work.mycsv_Temp;
  infile mycsv dlm=";" dsd;
 
input
    name :
$16.
    sex :
$1.
    age :
8.
  ;
run;

*
* append to existing using DATA Step view
*;

proc append
 
base=work.mycsv_base
 
data=work.mycsv_Temp
;
run;

View solution in original post


All Replies
Solution
‎10-06-2011 03:36 AM
SAS Super FREQ
Posts: 708

PROC APPEND ??

LiangCk
You can make use of DATA Step views, in this way there is no SAS Data set created by the DATA Step but a view.
The code for the view is executed when you access the view for instance when using Proc APPEND, see code below for a sample.
A question on the code sample you provided: is there a reason that you use infile/input as well as file/put, just curious.
Bruno
*
* create a DATA Step view
*;

data work.mycsv_Temp / VIEW=work.mycsv_Temp;
  infile mycsv dlm=";" dsd;
 
input
    name :
$16.
    sex :
$1.
    age :
8.
  ;
run;

*
* append to existing using DATA Step view
*;

proc append
 
base=work.mycsv_base
 
data=work.mycsv_Temp
;
run;
Contributor
Posts: 21

PROC APPEND ??

Posted in reply to Bruno_SAS

Hi bruno,

     Thanks for replying my discussion.

      First, replying your question.

     Answer is YES, you are correct. I used it for creating a duplicate csv/file from the orginal file that i read. Something like duplication of a file or back up file.

     indir() = is actualy a file directory and inside () is file name.

     

     Beside, one question for sir, you mention using view. for my understanding, view is just create a temporary table in memory is it?

     what i done is registering a "TEMP" table in a physical way.

     Which one is much more better way? interm of performance and accurate?

     Thank you and sorry for my poor english level.

Best Regards:

Liang Ck

SAS Super FREQ
Posts: 708

PROC APPEND ??

Liang

When one is accessing a view (SQL or DATA Step), the data from the view is materialized and exists while reading from the view.

If you read the data from the view several times, it is usually better to make a SAS Data Set out of it.

Bruno

Contributor
Posts: 21

PROC APPEND ??

Posted in reply to Bruno_SAS

Hi Bruno,

Thank for your advice, i think i shall used back my method because this process related to dynamically read external file.

Static is much better...

Thanks again..

Liang Ck

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 616 views
  • 3 likes
  • 2 in conversation