BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
marianhabesland
Calcite | Level 5

I am trying to use deminited raw data to create a table with two variables with their populations. I wrote this code:

 

data WORK.Illus;
infile datalines delimiter= " ";

input      State        :$10.

              Population  :comma10.;

         datalines;

Washington 7,170,351

Ohio 11,613,423

;

 

I do not get any error statements, but my table looks like this. What do I do to get the entire state name and population values in the table?

Screen Shot 2017-09-21 at 10.26.31.png

1 ACCEPTED SOLUTION

Accepted Solutions
BD1
Calcite | Level 5 BD1
Calcite | Level 5

 

Have you tried dragging the state column width when you view the output table to see the whole state name?

For the values do you mean how do you get the commas appearing in your output table, just like your input datalines?

 

try adding the following line under your input statement:

 

format Population comma10.;

 

View solution in original post

4 REPLIES 4
Reeza
Super User

THis works for me.

 

I find it easier to set the INFORMAT first.

 

data WORK.Illus;
	infile datalines delimiter=" ";
	informat state $20. population comma20.;
	format population comma20.;
	input State Population;
	datalines;
Washington 7,170,351
Ohio 11,613,423
;
run;
ballardw
Super User

Try either widening the column for state or use Proc Print. I suspect the table viewer just isn't making the column wide enough to see the whole state name.

 

If you mean that you also want to display the population with commas then you need to explicitly assign a comma format for display.

 

Format population comma11.;

 

Since formats only control display not values SAS will unless otherwise instructed default to a BEST format to display numeric values.

 

Note that you may need a different delimiter to deal with New York, New Mexico, North and South Dakota, North and South Carolina if they are in your future data to read this way.

BD1
Calcite | Level 5 BD1
Calcite | Level 5

 

Have you tried dragging the state column width when you view the output table to see the whole state name?

For the values do you mean how do you get the commas appearing in your output table, just like your input datalines?

 

try adding the following line under your input statement:

 

format Population comma10.;

 

marianhabesland
Calcite | Level 5

Thanks, I didn't realize it was just the formatting of the table that did not let me see the whole variable. I thought it might be cutting it off for a reason. And yes, I wanted to display the commas, so that helps.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1150 views
  • 0 likes
  • 4 in conversation