Programming the statistical procedures from SAS

Question about $ sign

Reply
N/A
Posts: 0

Question about $ sign

I run following code:
data admit;
input ID $ 1-4 Name $ 6-19 Sex $ 21 Age 23-24
Date 26-27 Height 29-30 Weight 32-34
ActLevel $ 36-39 Fee 41-46;
format fee 6.2;
run;

I guess 'ID $1-4',it will produce a parameter,its width is 4,but I don't understand 'Sex $21' width is 1,why? And 'Weight 32-34' width is 8,why?

input ID $ 1-4 Name $ 6-19 Sex $ 21 Age 23-24
Date 26-27 Height 29-30 Weight 32-34
ActLevel $ 36-39 Fee 41-46;

Where is 5,20,22,25,28,31,35,40? Why omit them?
Valued Guide
Posts: 2,108

Re: Question about $ sign

Suggest you check out the chapter on reading raw data in the SAS/Base Concepts manual:

http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001112330.htm

The answers to most of your questions are there. The others can be found by reading about the INPUT statement in the SAS Language Reference Dictionary..

Doc Muhlbaier
Respected Advisor
Posts: 3,773

Re: Question about $ sign

> I run following code:
> data admit;
> input ID $ 1-4 Name $ 6-19 Sex $ 21 Age 23-24
> Date 26-27 Height 29-30 Weight 32-34
> ActLevel $ 36-39 Fee 41-46;
> format fee 6.2;
> run;
>
> I guess 'ID $1-4',it will produce a parameter,its
> width is 4,but I don't understand 'Sex $21' width is
> 1,why? And 'Weight 32-34' width is 8,why?
>

these are column number ranges and in SAS without other statements to define the variable attributes the column numbers serve that purpose.
$1-4 character length 4
$21 same as $21-21 character length 1
32-34 NO $ sign numeric. All numerics default to lenght 8.

>
> Where is 5,20,22,25,28,31,35,40? Why omit them?

Those columns are skipped. No mistery.

You need to read about COLUMN INPUT. That will answer most of your questions.

This INPUT statement syntax was developed with the very first SAS version from the late sixties. If may seem odd to some.
Ask a Question
Discussion stats
  • 2 replies
  • 58 views
  • 0 likes
  • 3 in conversation