Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to define variable name from data?

Status
Not open for further replies.

on818come

Programmer
Oct 6, 2008
22
US
Hello, you guys.

I'm trying to make new summary sheets, and modify a series of variables' name. First read files from Excel and change varible's name to the table's first line. Can anyone help me?

Thanks so much
 
If you use proc import, by default the variables are named using the first record of the file.

Unfortunately I don't have the add-on which allows you to import directly from Excel ("SAS/Access for PC Files" I think), so I can't test this directly, but to read a CSV file you'd do this...
Code:
proc import datafile='X:\blahblah\customer_counts.csv'
            out=WORK.ccounts
            DBMS=CSV
            ;
run;

To read in an excel file, the DBMS= is changed to EXCEL (or something similar, their are several EXCELx options for different versions of Excel, more info is in the Help files).
For more info, type PROC IMPORT in your code window, highlight it and hit F1.

I hope that helps...


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
The synatax is pretty much as Chris pointed out, only we don't need to specify DBMS as the extension for xls files identifies it.

Code:
proc import datafile='X:\blahblah\customer_counts.xls'
            out=WORK.ccounts
            ;
run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top