BookmarkSubscribeRSS Feed
edasdfasdfasdfa
Quartz | Level 8

So if you have many variables, how can you define them without having to write out each one in the input statement? I know that once you have them defined initially you can use variable lists and there are many other options like using _ALL_ , _NUMERIC_ etc, but how about initially. Do you have to type out 20 different variables?

 

 

2 REPLIES 2
Norman21
Lapis Lazuli | Level 10

You might find this discussion useful:

 

https://communities.sas.com/t5/SAS-Programming/Assigning-Multiple-Variables/td-p/582197

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

Astounding
PROC Star

SAS doesn't know the variable names you want to use unless you tell it.  But if there is a pattern to the variable names, you can define them on the INPUT statement.  For example:

 

input @21 (q1-q20) (2. 1.);

This defines 20 variables, the odd-numbered variables being read from 2 characters of the input data line, and the even-numbered variables being read from 1 character.  So Q1 comes from columns 21-22, Q2 from column 23, Q3 from columns 24-25 etc.

 

While there are many variations possible on this theme, you would need to spell out some detail.  For a more specific answer we would need to know about what the variable names are, as well as where they appear on the raw data line.  It might help to know whether you have an electronic list of the variable names, and what that list looks like (such as how wide they are and whether they are character or numeric).  If you have this information, there are a variety of ways available to provide that information to a SAS program.  But if you don't have it, there's no way for SAS to know.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 537 views
  • 1 like
  • 3 in conversation