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

run proc contents on all of your files, including the new categorical one.  There is apparently a difference between one or more of them.

robertrao
Quartz | Level 8

Hi,

Here are the attributes for the three datasets from the Proc Contents. Would you be able to tell me where the problem is????

This is like 'CATEGORIES dataset in your example....

*I got this by exporting one of the datasets which i am going to merge which has all combinations for my template into EXCEL, deleted the value column and imported back into SAS

Data Set Name        WORK.TEMPLATE_FINAL              Observations          55

          Member Type          DATA                                           Variables             1

          Engine               V9                                                      Indexes               0

          Created              Wed, Oct 24, 2012 08:36:24 AM    Observation Length    25

          Last Modified        Wed, Oct 24, 2012 08:36:24 AM    Deleted Observations  0

          Protection                                                                     Compressed            NO

          Data Set Type                                                                  Sorted                NO

          Label

          Data Representation  WINDOWS_32

          Encoding             wlatin1  Western (Windows)

Alphabetic List of Variables and Attributes

               #    Variable       Type    Len    Format    Informat    Label

               1    categorical    Char     25    $25.      $25.        categorical

*DATASET1;

Data Set Name        WORK.STATC_OUT                       Observations          55

         Member Type          DATA                                         Variables             2

         Engine               V9                                                      Indexes               0

         Created              Wed, Oct 24, 2012 08:36:01 AM    Observation Length    400

         Last Modified        Wed, Oct 24, 2012 08:36:02 AM    Deleted Observations  0

         Protection                                                                    Compressed            NO

         Data Set Type                                                               Sorted                NO

         Label

         Data Representation  WINDOWS_32

         Encoding             wlatin1  Western (Windows)

Alphabetic List of Variables and Attributes

                            #    Variable       Type    Len    Format

                            1    categorical    Char    200    $200.
                            2    value          Char    200    $200.

*DATASET2;

Data Set Name        WORK.STATQ_OUT                       Observations          49

         Member Type          DATA                                        Variables             2

         Engine               V9                                                    Indexes               0

         Created              Wed, Oct 24, 2012 08:36:06 AM    Observation Length    400

         Last Modified        Wed, Oct 24, 2012 08:36:06 AM    Deleted Observations  0

         Protection                                                                    Compressed            NO

         Data Set Type                                                                Sorted                NO

         Label

         Data Representation  WINDOWS_32

         Encoding             wlatin1  Western (Windows)

Alphabetic List of Variables and Attributes

                            #    Variable       Type    Len    Format

                            1    categorical    Char    200    $200.
                            2    value          Char    200    $200.

art297
Opal | Level 21

I would change the length of categorical in WORK.TEMPLATE_FINAL to $200 so that it matches your other files.  That COULD be the mismatch, but I don't have any way of testing it this morning.

art297
Opal | Level 21

Just tested it and, definitely, the length difference would definitely cause the error you received.

robertrao
Quartz | Level 8

Thats awesome. Finally. ...

Changed the length and format as well

I can only tell one thing ....the members are far far ahead of just answering a question... You are making us ask the right (Proper) Question tooo...and thinking what we are thinking being hundreds and thousands of miles apart!!!

One last question:

I thought Set statement will write one dataset below the other.....But whats happening when we write: How are we able to get the output as if we merged it????

data want;

set new1;

set new2;

run;

Could you also suggest me an article when I could get some good knowledge about classdata and idgroup usage in Proc summary??

art297
Opal | Level 21

The answer to your first question: it is called one-to-one matching.  According to the documentation, at http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000173782.htm, it can be described as follows:

Use multiple SET statements to perform one-to-one reading (also called one-to-one matching) of the specified data sets. The new data set contains all the variables from all the input data sets. The number of observations in the new data set is the number of observations in the smallest original data set. If the data sets contain common variables, the values that are read in from the last data set replace the values that were read in from earlier ones. See Combining One Observation with Many, Performing a Table Lookup, and Performing a Table Lookup When the Master File Contains Duplicate Observations for examples of one-to-one reading of data sets.


As for your question about the use of classdata and idgroup in proc summary, I've leave that to data_null or someone else who can point you in the right direction.  I, personally, learned about the method from data_null's examples.  The only documentation I'm aware of, other than papers, pages and posts by data_null and Mike Zdeb is:

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146734.htm



robertrao
Quartz | Level 8

Thanks a ton for the detailed information.

Regards

Astounding
PROC Star

Create your format using leading zeros:

value $sort

'AGE'='01'

...

;

robertrao
Quartz | Level 8

Hi ,

I can also do

invalue sort       <<<<<<<<no dollar and invalue

'AGE'=01          >>>>>>>>no quotes for 01

Regards

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 23 replies
  • 2556 views
  • 6 likes
  • 5 in conversation