SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
raj143
Calcite | Level 5

proc sql;

create table size as

select*from dictionary.tables

where libname="SASHELP";

quit;

proc format;

picture dd low - high="999999MB";

run;

data data;

set size;

size=filesize*(1024*1024);

keep memname filesize size;

format size dd.;

run;

check out the above program....is it right ?

if it is right ...i am not getting accurate result.....

please help by modifying the program.....give the best suggetions....

thank you inadvance.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Change to this:

size = filesize / 1024 / 1024;

Filesize contains the number of bytes. Dividing by 1024 gives you KB, dividing again gives you MB.

One more divsion would give you GB.

You could even use a multiplicator in the format and assign the format directly to filesize.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Change to this:

size = filesize / 1024 / 1024;

Filesize contains the number of bytes. Dividing by 1024 gives you KB, dividing again gives you MB.

One more divsion would give you GB.

You could even use a multiplicator in the format and assign the format directly to filesize.

andreas_lds
Jade | Level 19

Some things helping us to help you:

  • use {i} or running-man icon to post formatted code, this increases readability
  • explain the expected result

The SAS environment i have access to prints the following error message:

40         
41         data data;
                ____
                57
ERROR 57-185: DATA is not allowed in the DATA statement when option DATASTMTCHK=ALLKEYWORDS.  Check for a missing semicolon in the 
              DATA statement, or use DATASTMTCHK=NONE.

After renaming the dataset the numbers seem to be to high. Maybe using the standard format sizekmgw.d is what you need.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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