BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12
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
data_null__
Jade | Level 19
> 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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1217 views
  • 0 likes
  • 3 in conversation