Help using Base SAS procedures

dropping variables that are not one word

Reply
Frequent Contributor
Posts: 102

dropping variables that are not one word

hi, i want to drop a variable called "global company id"

how can i drop this?

simnply saying:

data work1;

set base1 (drop = global company key);

run;

is not working. thank you

Super User
Posts: 19,815

Re: dropping variables that are not one word

SAS doesn't  usually allow variable names with spaces, so either the variable name is actually global_company_id, or if it actually has spaces you need to refer to it as "global company id"n.

Frequent Contributor
Posts: 102

Re: dropping variables that are not one word

thank you so much for your kind reply Reeze:

this is what i got from proc contents

11 at       Num    8 F18.4              Assets - Total

  12 capx     Num    8 F18.4              Capital Expenditures

  13 ceq      Num    8 F18.4              Common/Ordinary Equity - Total

   9 conm     Char  57 $57.      $57.     Company Name

   5 consol   Char   2 $2.       $2.      Level of Consolidation - Company Annual Descriptor

  22 costat   Char   1 $1.       $1.      Active/Inactive Status Marker

when i view table i see Assets-total. is it possible to at instead of assets-total. it is very difficult to code by looking at the view table.

Super User
Posts: 19,815

Re: dropping variables that are not one word

Your variable NAME is AT and that's what you should use in your code.

Your variable LABEL is Assets-Total

You can switch the view in SAS by going to View>Column Names, but this doesn't 'stick'.

Yes its a pain in the ass.  Another option is to strip all labels from a dataset, but with truncated variable names that has its own problems. 

I believe the following line will remove the labels from all variables.

attrib _all_ label = "";

Super User
Posts: 11,343

Re: dropping variables that are not one word

If you use command instead of the point & click menu to open a data set: Vt <data set name goes here>;colnames; will open view table with names instead of labels.

Or better, open the Keys menu, default F9, and add a command to a key:

vt _last_; colnames;

Then pressing the key combination you selected will bring up the last created data set with column names.

Super User
Posts: 19,815

Re: dropping variables that are not one word

Thanks, that's handy.

I'd still prefer an option to have the column names show by default rather than the labels.

Trusted Advisor
Posts: 1,923

Re: dropping variables that are not one word

Steps 1 through 4 here make the column names the default

http://listserv.uga.edu/cgi-bin/wa?A2=ind0708d&L=sas-l&P=6458

Super User
Posts: 11,343

Re: dropping variables that are not one word

Posted in reply to PaigeMiller

And if you want to sort the data in the tables or make data edits add openmode=edit

Ask a Question
Discussion stats
  • 7 replies
  • 245 views
  • 8 likes
  • 4 in conversation