SAS obtains the file name and column name.

Source: Internet
Author: User
After studying two days of SAS, SAS can finally obtain the file name and column name.
// Obtain the file column name
Libname da "C: \ test ";
Data ex;
Set da. QQ;
Run;
Proc transpose data = ex out = ex2;
VaR _ all _; // the table cannot be completely transposed before it is added. Some columns are always missing.
Run;
Proc print data = ex2;
Run;

// Obtain the file name in a folder
Filename indata pipe 'dir c: \ Tes/B ';
Data file_list;
Length fname $50 .;
Infile indata truncover;/* infile statement for file names */
Input fname $50.;/* read the file names from the directory */
Call symput ('num _ FILES ', _ n _);/* store the record number in a macro variable */
Run;

// Call vs.net
String [] sasdatatext = {
"FILENAME indata pipe 'dir c: \ Tes/B '; Data file_list ;",
"Length fname $50 .;",
"Infile indata truncover ;",
"Input fname $50 .;",
"Call symput ('num _ FILES ', _ n _);",
"Run ;",
"Proc print ;",
"Run ;"
};
System. array sasarray = sasdatatext;
Sasworkspace. explorageservice. submitlines (ref sasdatatext );
Const int Len = 100;
Wsas. languageservicecarriagecontrol [] CCS;
Wsas. languageservicelinetype [] linetype;
String [] logline;
Sasworkspace. Export ageservice. flushlistlines (Len, out CCS, out linetype, out logline );
We call language service to submit the SAS data step and process step and receive log and list output. For how to execute SQL statements, refer to the following link.
Reading SAS data in. net using ADO and ADO. net
Http://support.sas.com/kb/25/276.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.