Hi,
I have a SAS dataset in which the format on a particular variable is Best12.
I changed to Best7. and applied it.
When I close the dataset and reopen it the format is still Best12.
How can I save the changes before closing the dataset?????
Regards
proc datasets library=yourlib nolist;
modify your_dataset;
format your_var best7.;
quit;
CTorres
You can use Proc DATASETS to permanently change the format of a variable. You do not need to open the dataset
CTorres
So IF I use the following code I can change the formats for variables in a dataset present in a particular library??????
Thanks
proc datasets library=sgflib;
modify dataset_name;
format price dollar6.2 ;
informat date mmddyy10.;
run;
Yes. And also remember to end the proc Datasets with a quit; statement.
Hi Robert,
Could you share the code you used that didn't work for you. I am curious because you can definitely apply a format permanently using the DATA step. Although you have to create a new copy of the data set. Using a FORMAT statement inside of DATA step will assign the format permanently.
data new;
set test;
format numvar best7.;
run;
Thanks,
M.
Hi, I believe the reason why C.Torres suggested the use of proc datasets is because you can avoid datastep processing like in your example writing to a new dataset. You are pretty much compiling, executing and doing the whole process that is something can be avoided.
You can assign a format even with an attribute statement, nevertheless proc datasets is a powerful procedure for managing SAS datasets.
HTH,
Naveen
Hi,
Thank you all for the reply.
I get the following error can someone help me understand the meaning and the place of mistake????
I have the dataset teamA in the teams library
Thanks
proc datasets library=teams nolist;
modify teamA;
format VAR1 best8.;
format var2 var3 var4 var5 best7.;
quit;
ERROR: The file teams.teamA (memtype=(DATA VIEW)) was not found, but appears on a MODIFYstatement.
Exactly that, there's no dataset named teamA in your library teams.
Proc datasets requires both a run and quit.
What's the output from the following, does it list teamA?
proc datasets library=teams;
run; quit;
yes. it does list TeamA...after running Proc Contents
I was thinking we do not have permission to change the format on the datasets........and maybe that's the reason its giving that ERROR????
Do you agree???
Regards
Proc contents or proc datasets?
I mean the error is with Proc Datasets..........
proc datasets library=teams nolist;
modify teamA;
format VAR1 best8.;
format var2 var3 var4 var5 best7.;
run;
quit;
Please post your output from the following proc datasets code:
The output should be in the log.
proc datasets library=teams;
run;quit;
This is all what I got in the log!!!
Apart from this there is a " results viewer " where I could see all the datasets in this library and TeamA exists there!!!!
2492 proc datasets library=teams;
2493
2494 run;
2494! quit;
NOTE: PROCEDURE DATASETS used (Total process time):
real time 0.17 seconds
user cpu time 0.12 seconds
system cpu time 0.00 seconds
memory 529.06k
OS Memory 26860.00k
Timestamp 12/30/2014 04:42:49 PM
Step Count 142 Switch Count 0
Proc datasets doesn't generate output to the results window, only the log, in SAS 9.3 at least.
If you're 100% sure it exists and the code below doesn't work, contact tech support.
proc datasets library=teams;
modify teamA;
format VAR1 best8. var2 var3 var4 var5 best7.;
run;
quit;
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!
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.