[sas-users] 2 Easy SAS questions - Response to Question 2

david.d.chapman at census.gov david.d.chapman at census.gov
Wed Sep 21 11:06:15 EDT 2011


when I look at data x, I still have my unformatted values.  I tried to add
a "label" following an example on labels, but I kept getting errors.

Formats are display devices.   The underlying data does not change; but, 
with different formats you can change how you display it.  A format may or 
may not be stored in the dataset.  In the example code below.  The file 
test has a format associated and stored with it and the file test2 does 
not.  You can tell by looking at the proc contents.

When the file test is displayed in a proc print without a format statement 
only 2 digits are displayed.  When file test2 is displayed without a 
format statement in a proc print, all the data is displayed.

A format can be taken off the file with a statement like "format x;" or 
changed with a "format x 4.;". 

 

Run the code below.




data test;
format x 2.;
do i=1 to 10;
x=int(  uniform(0) *100000);
output;
end;
proc contents data=test;run;

proc print data=test(obs=3);
run;

data test2;
do i=1 to 10;
x=int(  uniform(0) *100000);
output;
end;
proc contents data=test2;run;

proc print data=test2(obs=3);
run;

/* format used in print is different from format associated witht he file 
*/;
proc print data=test(obs=3);
format x 4.;
run;

/* no format used in print */;
proc print data=test;  /* test contains a format */;
format x ;
run;

/* format used in print is different from format associated witht he file 
*/;
proc print data=test;
format x 8.;
run;
 

David D. Chapman
Chief, Quality Assurance Staff
Economic Planning and Coordination Division
U.S. Census Bureau - Economic Statistics
Office: 301-763-6535
Cell: 703-498-5782
E-mail: david.d.chapman at census.gov 

Connect with us:




From:
elizabeth.may.nichols at census.gov
To:
sas-users at lists.census.gov
Date:
09/21/2011 10:33 AM
Subject:
[sas-users] 2 Easy SAS questions
Sent by:
sas-users-bounces at lists.census.gov



Question 1:
I have 200 character data and I want my proc print to wrap;

I have added, "options ls=200;"

What is the code so my output wraps and I can print it nicely?


Question 2:

I want to create a dataset where I format  the values in a variable.

I tried to

data x (keep=variablea);
set y;
format variablea $varfmt.;
run;

when I look at data x, I still have my unformatted values.  I tried to add
a "label" following an example on labels, but I kept getting errors.


Beth Nichols
Center for Survey Measurement
U.S. Census Bureau
301-763-1724
elizabeth.may.nichols at census.gov

_______________________________________________
sas-users mailing list
sas-users at lists.census.gov
http://lists.census.gov/mailman/listinfo/sas-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110921/f0a1c15a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 4056 bytes
Desc: not available
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110921/f0a1c15a/attachment-0001.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 660 bytes
Desc: not available
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110921/f0a1c15a/attachment-0004.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 646 bytes
Desc: not available
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110921/f0a1c15a/attachment-0005.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1177 bytes
Desc: not available
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110921/f0a1c15a/attachment-0006.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 654 bytes
Desc: not available
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110921/f0a1c15a/attachment-0007.gif>


More information about the sas-users mailing list