- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
* 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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
* 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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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