Help using Base SAS procedures

Clibbing variables in Text and Data in Excel

Reply
Contributor
Posts: 66

Clibbing variables in Text and Data in Excel

Hi
i am having variables in Text file with pipe delimited and the data for this is in another excel sheet how can i create a dataset out of this. In Base SAS,.
Super Contributor
Super Contributor
Posts: 3,174

Re: Clibbing variables in Text and Data in Excel

Investigate using PROC IMPORT.

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search, this topic/post:

proc import pipe delimited site:sas.com
Respected Advisor
Posts: 4,173

Re: Clibbing variables in Text and Data in Excel

If you're using SAS EG:
The import wizard (File/Import) makes reading data into SAS quite an easy task.
Contributor
Posts: 66

Re: Clibbing variables in Text and Data in Excel

But i want in base sas
Super Contributor
Super Contributor
Posts: 3,174

Re: Clibbing variables in Text and Data in Excel

You will need to use a DATA step approach. Refer to the SAS support http://support.sas.com/ website and the recommended Google advanced search argument for related technical and conference papers on the topic. Or use the website's SEARCH facility.

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 66

Re: Clibbing variables in Text and Data in Excel

i got the solution

/*First Read the variables in Excel sheet*/
PROC IMPORT OUT= WORK.var
DATAFILE= "C:\Documents and Settings\Desktop\var.xlsx"
DBMS=EXCEL REPLACE;
RANGE="sam$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

/*caputring all the variables in to macro varaiable*/
proc sql noprint;
select name into :name separated by " "
from dictionary.columns where libname="WORK" and memname="VAR";
quit;
/*datafile with obs*/
filename text "C:\Documents and Settings\Desktop\values.txt";
/*outputfile*/
filename output "C:\Documents and Settings\Desktop\Output.txt";

data _null_;
infile text;
file output;
if _N_ eq 1 then put "&name"; * put header row;
input; * read one row;
put _infile_; * write read buffer to second file;
run;

proc import out=final datafile="C:\Documents and Settings\Desktop\Output.txt" replace;
delimiter=" ";
getnames=yes;
run;

then import the output.txt in to new Dataset
Ask a Question
Discussion stats
  • 5 replies
  • 125 views
  • 0 likes
  • 3 in conversation